logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ashish Kulkarni" <ashish.kulkarn...@gmail.com>
Subject Question about logging to multiple files
Date Thu, 23 Aug 2007 20:24:42 GMT
Hi
I am using XML to define my logging properties,
I wanted to know if i can define 2 log files, and have logs in them
depending on which class is writing log file
for example

if the package is
com.test.me then the logs should be written to mylog.xml file

if the class is
com.test.me.my.Test then the logs should be written to mytest.log file.

Here is my XML file

<appender name="A1" class="org.apache.log4j.DailyRollingFileAppender" >
<param name="File" value="C:\\mylog.xml" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />

<layout class="org.apache.log4j.xml.XMLLayout">
</layout>
</appender>

<appender name="A2" class="org.apache.log4j.DailyRollingFileAppender" >
<param name="File" value="c:\\ mytest.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
</layout>
</appender>

<category name="com.test.me">
<priority value="debug" />

<appender-ref ref="A1" />
</category>


<category name="com.test.me.my.Test">
<priority value="debug" />

<appender-ref ref="A2" />
</category>


<root>

<appender-ref ref="A1" />
<appender-ref ref="A2" />

</root>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message