logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harp, George" <GH...@GAINSystems.com>
Subject RE: Duplicate logging messages
Date Wed, 10 Aug 2005 17:40:41 GMT
The following works ok. Is it bad not to have the root logger in the script
or does it create a default one?

Also, what is the syntax to send only 1 Priority level to a appender?

Lile say I wanted to send all INFO log messages to an appender?

And thanks for the fast responses it helps.

<?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>
   
   
</log4j:configuration>

-----Original Message-----
From: Schuweiler, Joel J. [mailto:Schuweiler.Joel@mayo.edu]
Sent: Wednesday, August 10, 2005 12:30 PM
To: 'Log4J Users List'
Subject: RE: Duplicate logging messages


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:GHarp@GAINSystems.com] 
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:Schuweiler.Joel@mayo.edu]
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:GHarp@GAINSystems.com] 
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:Schuweiler.Joel@mayo.edu]
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:GHarp@GAINSystems.com] 
Sent: Wednesday, August 10, 2005 12:07 PM
To: 'log4j-user@logging.apache.org'
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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message