niqiangpro-cell commented on issue #745:
URL: 
https://github.com/apache/logging-log4cxx/issues/745#issuecomment-5452895617

   The main motivation is to avoid creating log files when an appender is 
configured but never receives a log event. This can happen when the log level 
filters all message or logging is conditional. In those cases, eagerly creating 
files can leave many empty directories and log files behind, polluting log 
directories and making meaningful logs harder to identify. Also, Log4j provides 
similar behavior through its optional `createOnDemand` setting, which creates 
the file only when a log event is actually routed to the appender. 
(https://logging.apache.org/log4j/2.x/manual/appenders/file.html)
   
   The intended approach would open the file only once, on the first write, and 
retain that handle for subsequent writes. After initialization, each message 
would only make a simple check that the file is already open, rather than 
reopening or checking the filesystem each time.
   
   I see that this changes when file-opening errors are reported, from 
configuration time to the first write. I would be glad to have your thoughts on 
whether avoiding empty files is desirable enough to justify that trade-off.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to