You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Seaman, Sloan" <Sl...@ptilabs.com> on 2004/09/03 16:41:54 UTC

Logging to multiple files

I have a log4j config file like so:
	<appender name="test"
class="org.apache.log4j.DailyRollingFileAppender">
    	<param name="File"
value="/pti/projects/commons-audit/v1.0/conf/test.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd"/>
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d [%t] %-5p
%c - %m%n"/>
		</layout>
	</appender>

	<appender name="audit"
class="org.apache.log4j.DailyRollingFileAppender">
    	<param name="File"
value="/pti/projects/commons-audit/v1.0/conf/audit.log" />
		<param name="DatePattern" value="'.'yyyy-MM-dd"/>
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%d [%t] %-5p
%c - %m%n"/>
		</layout>
	</appender>
	
	<category name="com.ptilabs">
    		<priority value="debug" />
	        <appender-ref ref="test" />
	</category>

	<category name="com.ptilabs">
    		<priority value="audit#com.ptilabs.commons.audit.AuditLevel"
/>
	        <appender-ref ref="audit" />
	</category>

And then in my code I have:
LOG.audit(lc.getSubject(), "Select * from TEST"); // custom method
LOG.info("yo");

For some reason everything is going to the audit.log (both audit and info).

I have the audit level set as Level.DEBUG_INT - 1 and the sysLogEquiv set to
7

How do I get it so that LOG.audit sends msgs to one appender and LOG.info
goes to the other?  I thought what I did would work, but I must be missing
something.

Thanks!

--
Sloan