PavelTurk commented on issue #2007:
URL: 
https://github.com/apache/logging-log4j2/issues/2007#issuecomment-1827746885

   @ppkarwasz ,
   
   I totally agree with your last post.  You suggest to use 
`LogManager.shutdown();` at the end of my own shutdown hook - this is exactly 
what I am doing now. You say:
   
   > AFAIK the only way for Log4j JUL to detect that the application is 
shutting down is to use Runtime#addShutdownHook, but this works only after 
Shutdown#runHooks has been invoked. The Shutdown#logRuntimeExit method that 
causes the reinitialisation problem in your application happens before the 
Shutdown#runHooks call.
   
   I also agree with that.
   
   There are two reasons why I opened this issue:
   
   1. Please, consider this code `XXX.shutdown()`. Will you expect that `XXX` 
will work after executing the code? I won't. That's why I spent several hours 
trying to understand why my log files are empty. Imagine, that XXX is your 
computer. What will you say if it works after you shutdown it?
   2. As I understand (I may be wrong here!) JRE specs doesn't say where JRE 
writes last log message. If I am right then Log4j2 should support all possible 
cases. For example, if in Java 22+ they will add log message AFTER  
`Shutdown#runHooks` then all log files of all `log4j2` users will be empty. 
That's it.


-- 
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