ok in my log4j.properties i have
log4j.rootLogger = DEBUG , X
log4j.logger.com.apress.logging.log4j = DEBUG , Y
log4j.logger.com.apress.logging.log4j.additivity = false
log4j.appender.X=org.apache.log4j.ConsoleAppender
log4j.appender.X.layout=org.apache.log4j.PatternLayout
log4j.appender.X.layout.conversionPattern=[ %p ] %m ( rootLogger ) %n
log4j.appender.Y=org.apache.log4j.ConsoleAppender
log4j.appender.Y.layout=org.apache.log4j.PatternLayout
log4j.appender.Y.layout.conversionPattern=[ %p ] %m ( logger )%n
and in my class i have
[code]
public class LoggerDemo {
private static Logger logger = Logger.getLogger( LoggerDemo.class.getPackage().getName() );
public LoggerDemo( ){
}
public void doLoggin( String name ){
logger.debug( "Entered the doLogging method..");
String str = "Hello ";
String output = null;
if( name == null ){
output = "Anonymous";
logger.warn( "No name passed, set to anonymous...");
}
else {
output = str.concat( name );
logger.info( "Constructed the string object..."+ output);
}
logger.info( "printing the message...");
logger.debug( "Exiting the doLogging method...");
}
public static void main( String args[] ){
String name = args[ 0 ];
LoggerDemo demo = new LoggerDemo( );
demo.doLoggin( name );
}
}
[/code]
and the output on the console is
[java] [ DEBUG ] Entered the doLogging method.. ( logger )
[java] [ DEBUG ] Entered the doLogging method.. ( rootLogger )
[java] [ INFO ] Constructed the string object...Hello Stephen ( logger )
[java] [ INFO ] Constructed the string object...Hello Stephen ( rootLogger )
[java] [ INFO ] printing the message... ( logger )
[java] [ INFO ] printing the message... ( rootLogger )
[java] [ DEBUG ] Exiting the doLogging method... ( logger )
[java] [ DEBUG ] Exiting the doLogging method... ( rootLogger )
how to i get it to stop printing the to the root logger please
-
log4j and additivity flag (1 messages)
- Posted by: stephen smithstone
- Posted on: October 02 2004 11:41 EDT
Threaded Messages (1)
- log4j and additivity flag by stephen smithstone on October 02 2004 11:53 EDT
-
log4j and additivity flag[ Go to top ]
- Posted by: stephen smithstone
- Posted on: October 02 2004 11:53 EDT
- in response to stephen smithstone
please ignore i got it working