Chien Wei, I was working on trying to do the very thing you were. Attached is a xml configuration file that I used to do what your asking. You will need to use the DOMConfigurator class to do this. Hope this helps. Keith > -----Original Message----- > From: Chien Wei Tan [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 15, 2001 2:11 AM > To: LOG4J Users Mailing List; [EMAIL PROTECTED] > Subject: RE: Assigning Layouts to Priorities > > > > hi rob, > > thanks... i understand how to log different priorities to different > appenders... but i m actually after logging different layouts to different > priorities... any ideas? > > cheers, > chienwei > > -----Original Message----- > From: Robert Leftwich [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, 15 August 2001 9:19 AM > To: LOG4J Users Mailing List > Subject: Re: Assigning Layouts to Priorities > > > At 11:00 AM 15/08/2001, Chien Wei Tan wrote: > > > >Hi, > > > >Would anyone know if it is possible to define different layouts > (including > >conversion patterns) for different priorities, (either through the > >configuration file, or in the actual log4j classes), given a specific > >category. > > > >eg. MyApp is a dummy class thats gets an instance of Category, and uses > >DEBUG, INFO, WARN, ERROR, and FATAL. Is is possible to log > messages in such > >a way that: > > > > DEBUG uses PatternLayout, ConversionPattern=%10p (%F:%L) - %m%n > > INFO uses SimpleLayout > > WARN uses PatternLayout, ConversionPattern=%-4r [%t] %-5p %c %x > > - %m%n > > ERROR uses PatternLayout, ConversionPattern=%-5r %8p [%t] %c - > %m%n > > FATAL uses PatternLayout, ConversionPattern=%-5r [%t] %c - %m%n > > > > > >Any help would be greatly appreciated, > >chienwei > > This from Ceki yesterday: > > >What you can do is to log different priorities to different > appenders. You > >can then attach a different layout (e.g. a PatternLayout) to each > >appender. Hope this helps, Ceki > > > Robert > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" configDebug="true"> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d [%-5t] %-5p (%-15c) %m%n"/> </layout> <filter class="org.apache.log4j.varia.PriorityRangeFilter"> <param name="PriorityMin" value="DEBUG" /> <param name="PriorityMax" value="ERROR" /> <param name="AcceptOnMatch" value="true" /> </filter> </appender> <appender name="CONSOLE_FATAL" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d [%-5t] %-5p (%-15c) %m%n LOCATION : %l%n"/> </layout> <filter class="org.apache.log4j.varia.PriorityMatchFilter"> <param name="PriorityToMatch" value="FATAL" /> <param name="AcceptOnMatch" value="true" /> </filter> </appender> <root> <priority value="debug"/> <appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE_FATAL"/> </root> </log4j:configuration>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]