So instead of:
<category name="MyTest">
<priority value="INFO" />
<appender-ref ref="BatchLogFile"/>
</category>
This is better due to depreciation?
<logger name="MyTest">
<level value="INFO" />
<appender-ref ref="BatchLogFile"/>
</logger>
How would I get the logger to just print INFO messages and not INFO and
above?
I bought the book a few years ago has it been updated? And I can't find it
now so am wondering if it is worth buying again for more info?
-----Original Message-----
From: Schuweiler, Joel J. [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 10, 2005 12:45 PM
To: 'Log4J Users List'
Subject: RE: Duplicate logging messages
What I do is send everything that gets sent to the root logger to a null
apender.
I then define logger (also known as category, cat. Is deprecated) entries
based on logger names and set the level I should accept there. The log also
points to an appender.
If you want to send ALL info or higher log messages to X appender you would
just set the level of the root logger to info. I believe it is info by
default but I don't know for certain. <level value="info">
On the log4j site there is a link to a commercial document. As much as I
hated to buy it I did. All the information in this document can be found
online in bits and pieces everywhere. This document just groups it together
to make it easy to find. I would recommend it if you need speedy answers.
-----Original Message-----
From: Harp, George [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 10, 2005 12:41 PM
To: 'Log4J Users List'
Subject: RE: Duplicate logging messages
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:[EMAIL PROTECTED]
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:[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]
---------------------------------------------------------------------
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]