让 tomcat 在日志语句中记录 webapp 名称
使用tomcat的JULI日志记录(jdk日志记录的扩展),是否可以让日志语句包含webapp的上下文路径(例如/myapp)。我在 web.xml 中使用不同的配置参数部署了几次相同的 web 应用程序。了解哪个 Web 应用程序输出了哪些日志语句将非常有帮助。
目前,日志输出如下所示:
Feb 22, 2012 9:37:57 AM org.mypackage.MyClass init
INFO: Model has been initialized
Feb 22, 2012 9:37:57 AM org.mypackage.MyClass init
INFO: after loading model: 1329921477445
我希望能够在类名称之前包含 web 应用程序(或 web 应用程序名称)的上下文路径。类似的事情:
Feb 22, 2012 9:37:57 AM /mywebapp org.mypackage.MyClass init
INFO: Model has been initialized
Feb 22, 2012 9:37:57 AM /mywebapp org.mypackage.MyClass init
INFO: after loading model: 1329921477445
谢谢, 马特
Using tomcat's JULI logging (extension of jdk logging), is it possible to get log statements to include the context path of the webapp (for example /myapp). I have the same webapp deployed a few times with different configuration parameters in the web.xml. It would be very helpful to understand which webapp was spitting out which log statements.
Currently, the log output looks like:
Feb 22, 2012 9:37:57 AM org.mypackage.MyClass init
INFO: Model has been initialized
Feb 22, 2012 9:37:57 AM org.mypackage.MyClass init
INFO: after loading model: 1329921477445
I'd like to be able to include the context path of the webapp (or webapp name) before the class name. Something along these lines:
Feb 22, 2012 9:37:57 AM /mywebapp org.mypackage.MyClass init
INFO: Model has been initialized
Feb 22, 2012 9:37:57 AM /mywebapp org.mypackage.MyClass init
INFO: after loading model: 1329921477445
Thanks,
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的 Web 应用程序中使用 SLF4J 和 Logback。不要依赖 Java 日志记录 (JULI)。
Use SLF4J and Logback in your webapps. Do not rely on Java Logging (JULI).