这是我的 log4j.xml
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<!-- DAILY ROLLING -->
<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="MaxFileSize" value="10240KB" />
<!-- Keep one backup file -->
<param name="MaxBackupIndex" value="10" />
<param name="ImmediateFlush" value="true" />
<param name="Append" value="true" />
<param name="File" value="/usr/local/xmld/log/xmld-core.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="XMLD2[%t] [loadId(%X{loadID}) - %X{customer} - %X{configuration} - %X{filename}]: %-5p - %d{yyyy-MM-dd HH:mm:ss,SSS} (%F:%M:%L) %m%n" />
</layout>
</appender>
<!-- SYSLOG -->
<appender name="syslog" class="org.apache.log4j.net.SyslogAppender">
<param name="syslogHost" value="${hostName}" />
<param name="facility" value="LOCAL6" />
<param name="facilityPrinting" value="false" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="XMLD2[%t] [loadId(%X{loadID}) - %X{customer} - %X{configuration} - %X{filename}]: %-5p - %d{yyyy-MM-dd HH:mm:ss,SSS} (%F:%M:%L) %m%n" />
</layout>
</appender>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="XMLD2[%t] ${hostName} [loadId(%X{loadID}) - %X{customer} - %X{configuration} - %X{filename}]: %-5p - %d{yyyy-MM-dd HH:mm:ss,SSS} (%F:%M:%L) %m%n" />
<!-- %d (%c{1})[%5p] %m%n -->
</layout>
</appender>
<!-- ====== Categories ===== -->
<!-- core -->
<logger name="com.my.xmldelivery2.core">
<level value="DEBUG" />
<appender-ref ref="syslog" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</logger>
<logger name="com.my.commons.utils">
<level value="DEBUG" />
<appender-ref ref="syslog" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</logger>
<!-- hibernate -->
<logger name="org.hibernate">
<level value="INFO" />
<appender-ref ref="syslog" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</logger>
<!-- Apache VFS2 -->
<logger name="org.apache.commons.vfs2">
<level value="INFO" />
<appender-ref ref="syslog" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</logger>
该软件包com.my.commons.utils
是一个依赖项,而com.my.xmldelivery2.core
我的软件是。这是之后生成的log4j.xml maven install
。
但是在控制台日志中,我看不到有关 utils 包的任何信息。包名是正确的。我真的不明白我做错了什么。不得不说,前两个包中也用到了最后两个包。