I am using Spring, and upon completion I have @PreDestroy cleaning beans. I don’t understand why logging accidentally happens sometimes, and others fail.
Logger log = LogManager.getLogger(MyClass.class);
@PreDestroy
public void close() {
log.warn("Test");
}
Sometimes I get nothing (no "Test" is registered), in other cases I get:
[13:48:44] INFO MyClass: Test
If I include System.out.println("Is this run?");close () in the method, it will always print.
I'm not sure what is going on. I don’t know if this is because the JVM is shutting down and the log is dead ... but I thought it would throw some sort of exception?
Please note that the log is logged as a + stdout file, I don’t know if this will affect anything. Logging works fine for the other thousands of thousands of lines of code, but not for this.
. , .
EDIT: MyClass bean spring.xml.