Logback - 在单独的文件中记录 Catalina
Logback - log catalina in a separate file
我使用 Logback-Logging-Framework 配置了 TomEE,我需要将 TomEE/Catalina 输出记录到一个额外的 catalina.out 文件,而通常所有日志记录转到 application.log。
我想出了以下配置,但在我的 catalina.out 文件中仍然是所有的休眠语句..我如何分离日志语句?
我怎样才能只在一个单独的文件中记录给定的包?
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://logback.qos.ch/manual/configuration.html -->
<configuration scan="true" scanPeriod="60 seconds">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator" />
<!-- =============================================== -->
<!-- Logging TomEE/Catalina -->
<!-- =============================================== -->
<appender class="ch.qos.logback.core.FileAppender" name="FILE-CATALINA">
<file>${catalina.base}/logs/catalina.out</file>
<encoder>
<pattern>%d %-5p: [%c] %m %rEx{20} %n</pattern>
</encoder>
</appender>
<logger name="org.apache.catalina" level="INFO" additivity="false">
<appender-ref ref="FILE-CATALINA" />
</logger>
<!-- =============================================== -->
<!-- Logging Application -->
<!-- =============================================== -->
<appender class="ch.qos.logback.core.FileAppender" name="FILE-APP">
<file>${catalina.base}/logs/application.log</file>
<encoder>
<pattern>%d %-5p: [%c] %m %rEx{3} %n</pattern>
</encoder>
</appender>
<logger name="org.hibernate" level="INFO" />
<logger name="org.apache" level="INFO" />
<logger name="org.quartz" level="INFO" />
<!-- =============================================== -->
<!-- ROOT Logger -->
<!-- =============================================== -->
<root level="ERROR">
<!-- log packages with INFO and all errors -->
<appender-ref ref="FILE-APP" />
</root>
<root level="OFF">
<!-- only log package org.apache.catalina -->
<appender-ref ref="FILE-CATALINA" />
</root>
</configuration>
现在 catalina.out 日志仍然有休眠日志(因为休眠配置为 INFO):
2015-04-30 13:38:24,004 INFO : [org.apache.catalina.startup.Catalina] Initialization processed in 4949 ms
2015-04-30 13:38:24,033 INFO : [**org.apache.catalina**.core.StandardService] Starting service Catalina
2015-04-30 13:38:24,034 INFO : [org.apache.catalina.core.StandardEngine] Starting Servlet Engine: Apache Tomcat (TomEE)/7.0.47 (1.6.0)
2015-04-30 13:38:28,484 INFO : [org.hibernate.annotations.common.Version] HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
2015-04-30 13:38:28,506 INFO : [org.hibernate.Version] HHH000412: Hibernate Core {4.2.8.Final}
刚弄明白:
我删除了第二个根附加程序(根级别="OFF" ...)并且附加程序 FILE-CATALINA 仅从配置的附加程序引用中获取消息(不再有根级别消息)。
我使用 Logback-Logging-Framework 配置了 TomEE,我需要将 TomEE/Catalina 输出记录到一个额外的 catalina.out 文件,而通常所有日志记录转到 application.log。
我想出了以下配置,但在我的 catalina.out 文件中仍然是所有的休眠语句..我如何分离日志语句? 我怎样才能只在一个单独的文件中记录给定的包?
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://logback.qos.ch/manual/configuration.html -->
<configuration scan="true" scanPeriod="60 seconds">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator" />
<!-- =============================================== -->
<!-- Logging TomEE/Catalina -->
<!-- =============================================== -->
<appender class="ch.qos.logback.core.FileAppender" name="FILE-CATALINA">
<file>${catalina.base}/logs/catalina.out</file>
<encoder>
<pattern>%d %-5p: [%c] %m %rEx{20} %n</pattern>
</encoder>
</appender>
<logger name="org.apache.catalina" level="INFO" additivity="false">
<appender-ref ref="FILE-CATALINA" />
</logger>
<!-- =============================================== -->
<!-- Logging Application -->
<!-- =============================================== -->
<appender class="ch.qos.logback.core.FileAppender" name="FILE-APP">
<file>${catalina.base}/logs/application.log</file>
<encoder>
<pattern>%d %-5p: [%c] %m %rEx{3} %n</pattern>
</encoder>
</appender>
<logger name="org.hibernate" level="INFO" />
<logger name="org.apache" level="INFO" />
<logger name="org.quartz" level="INFO" />
<!-- =============================================== -->
<!-- ROOT Logger -->
<!-- =============================================== -->
<root level="ERROR">
<!-- log packages with INFO and all errors -->
<appender-ref ref="FILE-APP" />
</root>
<root level="OFF">
<!-- only log package org.apache.catalina -->
<appender-ref ref="FILE-CATALINA" />
</root>
</configuration>
现在 catalina.out 日志仍然有休眠日志(因为休眠配置为 INFO):
2015-04-30 13:38:24,004 INFO : [org.apache.catalina.startup.Catalina] Initialization processed in 4949 ms
2015-04-30 13:38:24,033 INFO : [**org.apache.catalina**.core.StandardService] Starting service Catalina
2015-04-30 13:38:24,034 INFO : [org.apache.catalina.core.StandardEngine] Starting Servlet Engine: Apache Tomcat (TomEE)/7.0.47 (1.6.0)
2015-04-30 13:38:28,484 INFO : [org.hibernate.annotations.common.Version] HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
2015-04-30 13:38:28,506 INFO : [org.hibernate.Version] HHH000412: Hibernate Core {4.2.8.Final}
刚弄明白:
我删除了第二个根附加程序(根级别="OFF" ...)并且附加程序 FILE-CATALINA 仅从配置的附加程序引用中获取消息(不再有根级别消息)。