tomcat 中特定于应用程序的访问日志?

发布于 11-23 15:06 字数 1507 浏览 9 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤城病女2024-11-30 15:06:44

愚蠢的错误...它读取的位置

<Valve class="org.apache.catalina.valves.AccessLogValve"

应该是

<Valve className=...

在此修复之后,配置按预期工作,从 META-INF 部署。

Dumb mistake... Where it reads

<Valve class="org.apache.catalina.valves.AccessLogValve"

it should be

<Valve className=...

after this fix, the config works as expected, deployed from META-INF.

轻拂→两袖风尘2024-11-30 15:06:44

我怀疑您正在处理的是类加载器问题:阀门类可能无法用于复制上下文 xml 的类加载器。我不认为会出现这种情况,但是如果您从 META-INF 中删除 context.xml 文件并将其复制到 conf/Catalina/localhost/Stubby.xml 中,阀门是否可以正常工作?

I suspect what you are dealing with is a class loader issue: the valve classes may not be available to the class loader that is copying the context xml. I wouldn't think that would be the case, but if you remove the context.xml file from META-INF and copy it into conf/Catalina/localhost/Stubby.xml does the valve work correctly?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文