记录成功/不成功的 Spring 上下文初始化
我需要在日志文件中记录 Spring 上下文是否已正确初始化。如果所有的bean都正确连接并加载,我需要记录它,以及不正确的初始化...
我已经创建了appender和日志文件,但问题是我不知道里面是否有东西Spring 记录这两个事件,我该怎么做。
I need to log whether the Spring context was initialized correctly in a log file. If all the beans were wired and loaded correctly, I need to log that, as well as an incorrect initialization...
I have created the appender and the log file, but the problem is that I don't know if there is something in Spring to log those two events and how can I do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于成功做到了这一点。在我的 log4j.properties 中为 ContextLoader 类添加了一个记录器,其级别为错误。然后将我的新附加程序附加到该记录器,这样我就可以在新日志文件中获取所有上下文加载错误。
谢谢
G。
Finally managed to do this. Added a logger in my log4j.properties for the ContextLoader class, with a level of ERROR. Then attached my new appender to that logger and this way I get all context loading errors in my new log file.
Thanks
G.