-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Failover Appender logic is not working properly #3622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How to handle partial configuration startup failures is currently a grey area in Log4j Core. We discussed this recently on The configuration problem you present in this issue is not a temporary problem accessing a resource, but a permanent one. IMHO it should either prevent the configuration from being used at all or propagate an exception to the caller (we can create a configuration property for this). |
Thank you for your reply. Actually, While working on Log4j version update from v1 to v2, a Failover Appender was necessary for my requirement.
But I couldn't find a test case to call the secondary appenders. I updated the logic like this, and it works without any issue. Actually what I understand from the name 'Failover Appender' is that,
I understand the idea of default configuration but since there is Secondary Appenders already provided in the configuration, so those could be use as optional appenders. These optional appenders are actually default appender when fails.
I think it is better to prevent the configuration from being used at all.
Thank you. |
What do you mean by "wrong path"? I think that the behavior of Log4j Core should be different, depending on the type of error:
In my understanding, users of Therefore I think that the problem is:
|
Description
While working on Log4j2 Failover appender, I saw the failovers appenders not executing properly. if you check the public start method of 'FailoverAppender' class, the logic says if the primary appender is null then it logs an error message and the error counter is increased by one. For that condition the super class 'start' method never executes and the FailoverAppender remains a non started appender. Because of this logic, for some reason primary Failover appender not initiated [like, file path not correct for RollingFile/File], the whole Failover appender will stop working and throw an non started appender error.
Configuration
Version: [Log4j version 2.17.0 - 2.24.3]
Operating system: [Windows/Mac/Linux]
JDK: [1.8,17]
Logs
Reproduction
This config file could be use for reproduction, simply pul an invalid path at the primary appender it will not add to the base config.getAppenders list, because of this the primary appender become null and the FailoverAppender eventually never start for primary appender failure.
The text was updated successfully, but these errors were encountered: