tomcat 中特定于应用程序的访问日志?
我正在尝试在 tomcat 中为我的 .war 应用程序配置独立的访问日志,但我无法找出失败的原因。
目的是对发送到我的应用程序的请求进行单独的访问日志记录,而不必依赖 tomcat 的全局访问日志。
我知道为此我应该创建自己的上下文配置文件,并使用 AccessLogValve 指定我将写入的位置。
我在应用程序的 WAR 文件中创建了 META-INF/context.xml,其内容为:
<Context path="/Stubby">
<Valve class="org.apache.catalina.valves.AccessLogValve"
rotatable="true"
directory="/var/SP/log/stubby"
prefix="access.log_"
suffix=""
fileDateFormat="yyyyMMdd_HH"
pattern="combined"
buffered="false"
resolveHosts="false"
/>
</Context>
启动 tomcat 时,我看到该文件已复制到 conf/Catalina/localhost/Stubby.xml,但在应用程序加载期间出现解析错误常规:
SEVERE: Begin event threw exception
java.lang.NullPointerException
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
(...)
Jul 13, 2011 6:16:12 PM org.apache.catalina.startup.ContextConfig processContextConfig
SEVERE: Parse error in context.xml for /Stubby
java.lang.NullPointerException
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2806)
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2832)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1359)
这里出了什么问题?我在声明中是否遗漏了任何强制属性?
I am trying to configure independent accesslogs for my .war application in tomcat, but I can't figure out what is failing.
The intention is to have separate access logging for requests going to my application, without having to rely on tomcat's global access log.
I understand that for this I should create my own context config file, with an AccessLogValve specifying where I'll write to.
I have created META-INF/context.xml in my application's WAR file with the content:
<Context path="/Stubby">
<Valve class="org.apache.catalina.valves.AccessLogValve"
rotatable="true"
directory="/var/SP/log/stubby"
prefix="access.log_"
suffix=""
fileDateFormat="yyyyMMdd_HH"
pattern="combined"
buffered="false"
resolveHosts="false"
/>
</Context>
When starting tomcat I see that this file is copied to conf/Catalina/localhost/Stubby.xml, but there is a parse error during the application load routine:
SEVERE: Begin event threw exception
java.lang.NullPointerException
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
(...)
Jul 13, 2011 6:16:12 PM org.apache.catalina.startup.ContextConfig processContextConfig
SEVERE: Parse error in context.xml for /Stubby
java.lang.NullPointerException
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2806)
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2832)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1359)
What is wrong here? Am I missing any mandatory property in the declaration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

愚蠢的错误...它读取的位置
应该是
在此修复之后,配置按预期工作,从 META-INF 部署。
Dumb mistake... Where it reads
it should be
after this fix, the config works as expected, deployed from META-INF.