简体   繁体   English

更改Tomcat 7下Apache Jackrabbit的日志级别

[英]Change log level for Apache Jackrabbit under Tomcat 7

I am attempting to view INFO- or DEBUG-level log messages for Apache Jackrabbit 2.7.X running under Tomcat 7. I've searched for awhile and found two different possibilities on how to do this: 我正在尝试查看在Tomcat 7下运行的Apache Jackrabbit 2.7.X的INFO或DEBUG级别的日志消息。我搜索了一段时间,发现了两种不同的实现方法:

  • Add a WEB-INF/log4j.xml file with the appropriate configuration 使用适当的配置添加WEB-INF / log4j.xml文件
  • Set Java-level properties, eg log4j.logger.org.apache.jackrabbit 设置Java级别的属性,例如log4j.logger.org.apache.jackrabbit

This seems like a simple task but thus far I've not been able to make either of the above work for me. 这似乎是一个简单的任务,但到目前为止,我还无法为我完成以上任何一项工作。

I am particularly interested in seeing some of the "internals", eg what data is received over the wire versus what is created in the repository, and so forth. 我对看到某些“内部”特别感兴趣,例如,通过网络接收的数据与在存储库中创建的数据等等。 I don't even know if this is possible but I figure logging everything is a good place to start. 我什至不知道这是否可行,但我认为记录所有内容是一个不错的起点。

About 10 minutes after posting this I found the answer, so here it is in case somebody is trying to do the same and finds this at a later date. 发布此内容大约10分钟后,我找到了答案,因此在此情况下,是为了防止有人尝试这样做并在以后找到它。

Although the documentation says: 尽管文档说:

Are there any notable log entries? 是否有任何值得注意的日志条目? Check the log files for any related warnings or errors. 检查日志文件中是否有任何相关的警告或错误。 By default the Jackrabbit JCR Server writes log entries to the standard output of the servlet container. 默认情况下,Jackrabbit JCR Server将日志条目写入servlet容器的标准输出。 You can customize logging by editing the /WEB-INF/log4j.xml file and redeploying this web application. 您可以通过编辑/WEB-INF/log4j.xml文件并重新部署此Web应用程序来自定义日志记录。

This appears to be incorrect as in fact the newer Jackrabbit uses logback, and the configuration file in the standard distribution is: 这似乎是不正确的,因为实际上较新的Jackrabbit使用logback,并且标准分发中的配置文件为:

 WEB-INF/classes/logback.xml

In which you can change the basic level and append to the console as such: 您可以在其中更改基本级别并按如下方式附加到控制台:

  <root level="DEBUG">
    <appender-ref ref="console"/>
  </root>

You can get more advanced from there, it appears. 您可以从那里得到更高级的提示。 Make the change, restart the container, and you're good to go. 进行更改,重新启动容器,一切顺利。

On jackrabbit 2.10.1, you should put this in WEB-INF/classes/logback.xml 在jackrabbit 2.10.1上,应将其放在WEB-INF / classes / logback.xml中

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-40([%thread] %F:%L) %msg%n</pattern>
    </encoder>
  </appender>

  <root level="DEBUG">
    <appender-ref ref="console"/>
  </root>

</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM