我通过tomcat运行Spring并使用Log4j。我最近添加了一个spring bean来处理Spring Integration组件的正常关闭。
这一切正常但我的destroy方法中的日志输出丢失了 - 我认为这是因为log4j已经被终止了。我可以使用System.out看到输出。
我的bean的destroy方法是从spring config" destroy-method" bean内部的日志记录是通过:
private final static Logger LOGGER = Logger.getLogger(Monitor.class.getName());
...
LOGGER.info("Application shutdown started");
我在类路径上有log4j(这是Spring知道它的唯一方法)和log4j.properties文件。
我在想因为我的bean不直接依赖log4j,Spring在我的destroy()方法之前终止它。
在我完成destroy()之前,有没有人知道Spring保持log4j的方法?