以下是我的log4j.xml
:
<appender name="logfile" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="somelog.log" />
<param name="Append" value="true" />
<param name="DatePattern" value="'.'yyyy-MM-dd-a" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{HH:mm:ss,SSS} %-5p [%t]: %c{1} (%X{RequestId}) - %m%n" />
</layout>
</appender>
<appender name="exceptionServiceSoap"
class="org.apache.log4j.DailyRollingFileAppender">
<param name="file" value="somelog1.log" />
<param name="Append" value="true" />
<param name="DatePattern" value="'.'yyyy-MM-dd-a" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{HH:mm:ss,SSS} %-5p [%t]: %c{1} (%X{RequestId}) - %m%n" />
</layout>
</appender>
<logger name="org.codehaus.xfire" additivity="true">
<level value="INFO" />
<appender-ref ref="exceptionServiceSoap"/>
</logger>
<category name="org">
<priority value="WARN" />
</category>
<category name="org.hibernate.SQL">
<priority value="ERROR" />
</category>
<category name="com">
<priority value="WARN" />
</category>
<category name="httpclient">
<priority value="WARN" />
</category>
<root>
<appender-ref ref="logfile" />
</root>
我希望在包“org.codehaus.xfire
”内生成的日志使用appender“exceptionServiceSoap
”,并且出于所有其他目的,应该使用appender“logfile
”,但上面的设置日志为“{ {1}}“进入两个appender。我怎么能避免这个?
答案 0 :(得分:0)
我不是百分百肯定,但你可以试试这个:
<Loggers>
<Logger name="org.codehaus.xfire" level="all" additivity="false">
<AppenderRef ref="exceptionServiceSoap"/>
</Logger>
<Root level="all">
<AppenderRef ref="logfile"/>
</Root>
</Loggers>
此外,您的附加内容应位于代码中:<Appenders>...</Appenders>