如何将 logback-access 与 Tomcat 5.5 结合使用?
我在 Tomcat 5.5 服务器上运行了多个 Web 应用程序,并且我正在努力改进/更新整个系统中使用的整体日志记录系统。 我已经在 logback-classic 方面取得了一些成功。 但是,当我尝试使用 logback-access (即访问 lbAccessStatus servlet)时,我收到此异常:
exception javax.servlet.ServletException: Wrapper cannot find servlet class ch.qos.logback.access.ViewStatusMessagesServlet or a class it depends on org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433) ... root cause java.lang.ClassNotFoundException: ch.qos.logback.access.ViewStatusMessagesServlet org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386) ...
我已根据 docs:
common/lib: logback-classic-0.9.15.jar logback-core-0.9.15.jar server/lib: logback-access-0.9.15.jar
在库中移动似乎没有帮助。 logback-classic 似乎工作正常,只是 logback-access 导致了问题。
I've got several Web apps running on a Tomcat 5.5 server, and I'm working on improving/updating the overall logging system used throughout the system. I already had some success with logback-classic. However, when I try to use logback-access (i.e. access the lbAccessStatus servlet), I get this exception:
exception javax.servlet.ServletException: Wrapper cannot find servlet class ch.qos.logback.access.ViewStatusMessagesServlet or a class it depends on org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433) ... root cause java.lang.ClassNotFoundException: ch.qos.logback.access.ViewStatusMessagesServlet org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386) ...
I have everything set up according to the docs:
common/lib: logback-classic-0.9.15.jar logback-core-0.9.15.jar server/lib: logback-access-0.9.15.jar
Moving around the libraries doesn't seem to help. logback-classic seems to work fine, it's just logback-access that causes problems.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经成功了。 使用maven和logback-classic,jars以WEB-INF/lib结尾,并且运行良好。
仅当部署旧版本的 WAR 时,我才看到相同的错误。
我的 pom.xml 的依赖项部分摘录
...以及我的 web.xml 的相关部分:
I've got it working. With maven and logback-classic the jars end in WEB-INF/lib and it works well.
I've seen the same error only when deploying old version of my WAR.
excerpt of dependencies section of my pom.xml
... and relevant part of my web.xml:
我还没有在 tomcat 中使用 logback-access 。 我只将它与 jetty 一起使用...
不过,我建议尝试以下设置:
logback-access 将 logback-core 作为依赖项。 由于您在服务器(Valve)和 Web 应用程序(ViewStatusMessagesServlet)中都使用它,因此您应该将其添加到两个类路径中。
您还可以(并且应该?)将 logback-access、logback-classic 和 logback-core 添加到您的 web 应用程序类路径中,而不是将其添加到 common/lib 中,使其可供所有 web 应用程序使用。
希望有帮助。
I haven't used logback-access with tomcat, yet. I only used it with jetty...
I'd suggest to try the following setup, though:
logback-access has logback-core as a dependency. Since you use it both in the server (the Valve) and in your webapp (the ViewStatusMessagesServlet) you should add it to both classpaths.
You could (and should?) also add logback-access, logback-classic and logback-core to your webapp classpath instead of adding it to common/lib, making it available to all webapps.
Hope that helps.
如果你也把 logback-access 放在 common/lib 中,那么所有的 jar 都在那里,它应该在任何地方都可用。 你尝试过吗?
Tomcat 6 中的日志记录也已重新设计。是否可以升级?
If you put logback-access in common/lib too, so all the jars are there, it should be available everywhere. Have you tried that?
Also logging has been reworked in Tomcat 6. Is upgrading a possibility?