You have to name your loggers something different and then use the category to get the different log messages sent to another appender.
-----Original Message----- From: Harp, George [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 10, 2005 12:14 PM To: 'Log4J Users List' Subject: RE: Duplicate logging messages I would like to set the default log level for the appender = BatchLogFile to be info and then use the category syntax to set the log level for specified classes to debug. -----Original Message----- From: Schuweiler, Joel J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 10, 2005 12:12 PM To: 'Log4J Users List' Subject: RE: Duplicate logging messages You must have a root logger. I'm confused on what you are asking for. -----Original Message----- From: Harp, George [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 10, 2005 12:11 PM To: 'Log4J Users List' Subject: RE: Duplicate logging messages do I need to set a root logger? I am asking how do I change this? -----Original Message----- From: Schuweiler, Joel J. [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 10, 2005 12:09 PM To: 'Log4J Users List' Subject: RE: Duplicate logging messages Your root logger, and your category/logger both call the same appender. -----Original Message----- From: Harp, George [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 10, 2005 12:07 PM To: '[email protected]' Subject: Duplicate logging messages Hello I am using log4j.1.2.9.jar and when I use the category element I get duplicate log messages. I am enclosing the code and a log4j.xml that works and the one that duplicates the log messages. Can you please tell me what I am messing up? I need to be able to set the default logging level for a appender and then designate selected classes to have a different log level. Help? MyTest.java: import org.apache.log4j.Logger; public class MyTest { private static Logger logger_m = Logger.getLogger( MyTest.class ); public static void main( String[ ] args ) { logger_m.info( "Began" ); logger_m.info( "Ended" ); } } log4j.xml that does not duplicate log messages: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <!-- Make debug="true" attribute for parsing information --> <log4j:configuration debug="null" xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="BatchLogFile" class="org.apache.log4j.FileAppender"> <param name="File" value="${user.dir}/BatchLogFile.log"/> <param name="Threshold" value="INFO"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{dd-MM-yyyy HH:mm:ss} %-9.9p %-19.19C{1} %-19.19M %m%n"/> </layout> </appender> <root> <appender-ref ref="BatchLogFile"/> </root> </log4j:configuration> logj4.xml that duplicates log messages: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <!-- Make debug="true" attribute for parsing information --> <log4j:configuration debug="null" xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="BatchLogFile" class="org.apache.log4j.FileAppender"> <param name="File" value="${user.dir}/BatchLogFile.log"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{dd-MM-yyyy HH:mm:ss} %-9.9p %-19.19C{1} %-19.19M %m%n"/> </layout> </appender> <category name="MyTest"> <priority value="INFO" /> <appender-ref ref="BatchLogFile"/> </category> <root> <appender-ref ref="BatchLogFile"/> </root> </log4j:configuration> --------------------------------------------------------------------- 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] --------------------------------------------------------------------- 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] --------------------------------------------------------------------- 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]
