ppkarwasz commented on issue #3622:
URL: 
https://github.com/apache/logging-log4j2/issues/3622#issuecomment-2841540961

   > While testing the Failover Appender, I tried with some approaches, like
   > 
   > 1. Put wrong path in Primary Appender  path variable
   > 2. Throw an error at Primary Appender
   > 3. Lock the log file [The appender I was using, was a RollingFile]
   >     so on...
   
   What do you mean by "wrong path"? I think that the behavior of Log4j Core 
should be different, depending on the type of error:
   
   1. If this is an invalid path in your OS (e.g. a path containing `:` or 
other forbidden characters on Windows), then Log4j Core should refuse to start 
such a configuration.
   2. If the path is valid, but an error occurs while creating it, the behavior 
should depend on the [`createOnDemand` 
option](https://logging.staged.apache.org/log4j/2.x/manual/appenders/file.html#FileAppender-attr-createOnDemand).
 If it is `false`, then the whole configuration shouldn't start, otherwise the 
appender should be created and try to open the file at each log event.
   
   > > How to handle partial configuration startup failures is currently a grey 
area in Log4j Core. We [discussed this recently on 
dev@logging](https://lists.apache.org/thread/h2oydyk6xld47ljttqvflbt4530o73vw) 
and the consensus is that in cases like yours the whole Configuration object 
should be discarded and the old configuration should be used (or the default 
configuration if the first configuration fails). Would this be an acceptable 
solution?
   > 
   > 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.
   
   In my understanding, users of `FailoverAppender` want to use the primary 
appender most of the time. The secondary appenders are there to temporarily 
relief the primary appender if it fails, but most of the time the primary 
appender should be used.
   
   Therefore I think that the problem is:
   
   - `RollingFileAppender` should not fail in its constructor if a temporary 
problem is detected. If it fails the whole configuration should fail with it.
   - `RollingFileAppender` should try to open the log file in its `start` 
method, not the constructor. Until `start` is called, the appender should not 
use any resources.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to