如何为一场战争拥有单独的tomcat日志
我正在使用一个 war,它根据资源(即调用它的 URL)以不同的方式使用。
这些资源是从网络应用程序外部访问的。
我需要维护单独的日志,以便可以单独维护所有日志。因此,我需要有一个文件夹日志,例如 webapps 外部的资源文件夹。
I am using a single war which is used in different way depending on the resources (ie. the URL by which it is called).
The resources are accessed from outside the webapps.
I need to maintain separate logs so that all the logs can be maintained separately.So i need to have a folder logs like the resources folder outside the webapps for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
好吧,有一种方法可以使用 log4j 来做到这一点。我并不是说这是最好的方法,但这个方法应该有效。这是一个起点。
下载
log4j.jar
并将其放入您的WEB-INF/lib
在
WEB-INF/classes< 中有一个
log4j.properties
/代码>。看起来像这样现在,从您的应用程序中获取正确记录器的句柄
在您的日志文件夹中,您应该有 2 个名为
tomcatlog4j.log
和tomcatlog4j_newsite.log
的日志文件> 带有正确的信息。即使没有 log4j,也可能有一种方法可以在 Tomcat 中执行此操作,但我还没有工作示例
Okay there is a way to do this using log4j. I'm not saying this is the best way, but this method should work. Here's a starting point.
Download
log4j.jar
and put it in yourWEB-INF/lib
Have a
log4j.properties
inWEB-INF/classes
. It will look like thisNow from your app, get a handle to the right logger
In your logs folder, you should have the 2 log files named
tomcatlog4j.log
andtomcatlog4j_newsite.log
with the right messages.There could be a way to do this in Tomcat even without log4j, but I dont have a working sample yet