Re: Setting up log4j.xml

2006-12-05 Thread Bender Heri
Log events which are sent to a specialized Logger (=not Root Logger) will by 
default climb up the logger hierarchy until the root logger and serve every 
appender of every logger found on its way. Your example: a log event sent to 
logger named loggingexample.Main arrieves to this logger, does not find an 
appender, looks up the next upper logger in hierarchy, finds the root logger 
with level DEBUG and serves its appender A1.

To achieve what you want, supply the logger loggingexample.Main with the 
appender-ref A1 and set the logger's property additivity=false. This will 
prevent the log event to climb further up the hierarchy.

logger name=loggingexample.Main additivity=false
 level value=error/
 appender-ref ref=A1 /
 /logger

Heri

 -Original Message-
 From: chuanjiang lo [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 05, 2006 7:59 AM
 To: Log4J Users List
 Subject: [SPAM (Bayesain Analysis)] - Re: Setting up log4j.xml -
 Bayesian Filter detected spam
 
 
 i'm having this config..
 i would like to print out error and fatal msgs in the Main class of
 loggingexample package, how come it is still printing debug 
 level and above
 msgs?
 
 appreciate any help
 
 appender name=A1 class=org.apache.log4j.ConsoleAppender
 layout class=org.apache.log4j.PatternLayout
 !-- Print the date in ISO 8601 format --
 param name=ConversionPattern value=%d [%t] 
 %-5p %c - %m%n/
 
 /layout
 /appender
 
logger name=loggingexample.Main
 level value=error/
 /logger
 
 root
 level value=debug/
 appender-ref ref=A1 /
 /root
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Setting up log4j.xml

2006-12-05 Thread chuanjiang lo

On 12/5/06, Bender Heri [EMAIL PROTECTED] wrote:


Log events which are sent to a specialized Logger (=not Root Logger) will
by default climb up the logger hierarchy until the root logger and serve
every appender of every logger found on its way. Your example: a log event
sent to logger named loggingexample.Main arrieves to this logger, does
not find an appender, looks up the next upper logger in hierarchy, finds the
root logger with level DEBUG and serves its appender A1.

To achieve what you want, supply the logger loggingexample.Main with the
appender-ref A1 and set the logger's property additivity=false. This will
prevent the log event to climb further up the hierarchy.

logger name=loggingexample.Main additivity=false
 level value=error/
 appender-ref ref=A1 /
 /logger

Heri



This is my current xml configuration..somehow the class Main still prints
out those levels that are below error.

log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/;
debug=false

   appender name=A1 class=org.apache.log4j.ConsoleAppender
   layout class=org.apache.log4j.PatternLayout
   !-- Print the date in ISO 8601 format --
   param name=ConversionPattern value=%d [%t] %-5p %c - %m%n/

   /layout
   /appender

   logger name=loggingexample.Main additivity=false
   level value=error/
   appender-ref ref=A1/
   /logger

   root
   level value=debug/
   appender-ref ref=A1/
   /root
/log4j:configuration


RE: Setting up log4j.xml

2006-12-05 Thread Bender Heri
It shouldn't. Maybe you are not fetching the logger correctly. How you 
instantiate the logger in the Main class? It should be:

Logger.getLogger( loggingexample.Main )

or

Logger.getLogger( this.getClass() )

The latter is only valid if loggingexample.Main is exactly the FQCN of MAIN 
(normally there is a a toplevel domain in front, i.e. 
com.loggingexample.Main).

Try it with annother appender (maybe FileAppender) for the 
loggingexample.Main-Logger. So you can see which logger outputs the event.

Heri

 -Original Message-
 From: chuanjiang lo [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 05, 2006 12:30 PM
 To: Log4J Users List
 Subject: Re: Setting up log4j.xml
 
 
 On 12/5/06, Bender Heri [EMAIL PROTECTED] wrote:
 
  Log events which are sent to a specialized Logger (=not 
 Root Logger) will
  by default climb up the logger hierarchy until the root 
 logger and serve
  every appender of every logger found on its way. Your 
 example: a log event
  sent to logger named loggingexample.Main arrieves to this 
 logger, does
  not find an appender, looks up the next upper logger in 
 hierarchy, finds the
  root logger with level DEBUG and serves its appender A1.
 
  To achieve what you want, supply the logger 
 loggingexample.Main with the
  appender-ref A1 and set the logger's property 
 additivity=false. This will
  prevent the log event to climb further up the hierarchy.
 
  logger name=loggingexample.Main additivity=false
   level value=error/
   appender-ref ref=A1 /
   /logger
 
  Heri
 
 
 This is my current xml configuration..somehow the class Main 
 still prints
 out those levels that are below error.
 
 log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/;
 debug=false
 
 appender name=A1 class=org.apache.log4j.ConsoleAppender
 layout class=org.apache.log4j.PatternLayout
 !-- Print the date in ISO 8601 format --
 param name=ConversionPattern value=%d [%t] 
 %-5p %c - %m%n/
 
 /layout
 /appender
 
 logger name=loggingexample.Main additivity=false
 level value=error/
 appender-ref ref=A1/
 /logger
 
 root
 level value=debug/
 appender-ref ref=A1/
 /root
 /log4j:configuration
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Setting up log4j.xml

2006-12-05 Thread Jacob Kjome

Bender,

You are correct in your latest analysis, but incorrect on your original
analysis.  Chuanjiang's original XML file was just fine and the fact that he
increased the level to error should have made it so that only ERROR messages
would print to the A1 appender for that specific logger, while all other
loggers would print to the debug level.

There are a couple possibilities why this might not be working.

1.  As you mentioned, the logger name might not exactly match that being
referenced in the log4j.xml file

2.  Another config file is being used instead of this one.


Note that the approach I would generally take to configuration is to set the
root logger to some higher level such as warn and then selectively set
loggers to debug where I truly want to see debug output.


Jake

Quoting Bender Heri [EMAIL PROTECTED]:

 It shouldn't. Maybe you are not fetching the logger correctly. How you
 instantiate the logger in the Main class? It should be:

 Logger.getLogger( loggingexample.Main )

 or

 Logger.getLogger( this.getClass() )

 The latter is only valid if loggingexample.Main is exactly the FQCN of MAIN
 (normally there is a a toplevel domain in front, i.e.
 com.loggingexample.Main).

 Try it with annother appender (maybe FileAppender) for the
 loggingexample.Main-Logger. So you can see which logger outputs the event.

 Heri

  -Original Message-
  From: chuanjiang lo [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, December 05, 2006 12:30 PM
  To: Log4J Users List
  Subject: Re: Setting up log4j.xml
 
 
  On 12/5/06, Bender Heri [EMAIL PROTECTED] wrote:
  
   Log events which are sent to a specialized Logger (=not
  Root Logger) will
   by default climb up the logger hierarchy until the root
  logger and serve
   every appender of every logger found on its way. Your
  example: a log event
   sent to logger named loggingexample.Main arrieves to this
  logger, does
   not find an appender, looks up the next upper logger in
  hierarchy, finds the
   root logger with level DEBUG and serves its appender A1.
  
   To achieve what you want, supply the logger
  loggingexample.Main with the
   appender-ref A1 and set the logger's property
  additivity=false. This will
   prevent the log event to climb further up the hierarchy.
  
   logger name=loggingexample.Main additivity=false
level value=error/
appender-ref ref=A1 /
/logger
  
   Heri
 
 
  This is my current xml configuration..somehow the class Main
  still prints
  out those levels that are below error.
 
  log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/;
  debug=false
 
  appender name=A1 class=org.apache.log4j.ConsoleAppender
  layout class=org.apache.log4j.PatternLayout
  !-- Print the date in ISO 8601 format --
  param name=ConversionPattern value=%d [%t]
  %-5p %c - %m%n/
 
  /layout
  /appender
 
  logger name=loggingexample.Main additivity=false
  level value=error/
  appender-ref ref=A1/
  /logger
 
  root
  level value=debug/
  appender-ref ref=A1/
  /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]



Re: Setting up log4j.xml

2006-12-05 Thread chuanjiang lo

On 12/6/06, Jacob Kjome [EMAIL PROTECTED] wrote:



Bender,

You are correct in your latest analysis, but incorrect on your original
analysis.  Chuanjiang's original XML file was just fine and the fact that
he
increased the level to error should have made it so that only ERROR
messages
would print to the A1 appender for that specific logger, while all other
loggers would print to the debug level.

There are a couple possibilities why this might not be working.

1.  As you mentioned, the logger name might not exactly match that being
referenced in the log4j.xml file

2.  Another config file is being used instead of this one.


Note that the approach I would generally take to configuration is to set
the
root logger to some higher level such as warn and then selectively set
loggers to debug where I truly want to see debug output.


Jake




Appreciate all help,

Indeed the logger name is does not match the one being referenced in the
log4j.xml file.

instead of
Logger mylogger = Logger.getLogger(Main );

should be
Logger mylogger = Logger.getLogger(loggingexample.Main );

Should have check throughly.
Thanks guys


Re: Setting up log4j.xml

2006-12-04 Thread chuanjiang lo

i'm having this config..
i would like to print out error and fatal msgs in the Main class of
loggingexample package, how come it is still printing debug level and above
msgs?

appreciate any help

   appender name=A1 class=org.apache.log4j.ConsoleAppender
   layout class=org.apache.log4j.PatternLayout
   !-- Print the date in ISO 8601 format --
   param name=ConversionPattern value=%d [%t] %-5p %c - %m%n/

   /layout
   /appender

  logger name=loggingexample.Main
   level value=error/
   /logger

   root
   level value=debug/
   appender-ref ref=A1 /
   /root


Re: Setting up log4j.xml

2006-12-02 Thread James Stauffer

Set a threshold on info appender and send root logs to both appenders.

On 12/2/06, chuanjiang lo [EMAIL PROTECTED] wrote:

Hi all,

I would like to know how i can set up my log4j.xml, for e.g info level would
be printed onto the console where debug level would be log into a file.

These are the snippets of my log4j.xml

appender name=info-appender class=org.apache.log4j.ConsoleAppender
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%d{dd MMM  HH:mm:ss}
[%t] %-5p %c - %m%n/
/layout
/appender

appender name=debug-appender class=org.apache.log4j.FileAppender
param name=file value=debug.log/
layout class=org.apache.log4j.SimpleLayout/
/appender

root
priority value=debug/
appender-ref ref=debug-appender/
/root

I'm not very sure how i can set up the environment, probably need some
advice from experienced users.

Appreciate any help





--
James Staufferhttp://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Setting up log4j.xml

2006-12-01 Thread chuanjiang lo

Hi all,

I would like to know how i can set up my log4j.xml, for e.g info level would
be printed onto the console where debug level would be log into a file.

These are the snippets of my log4j.xml

appender name=info-appender class=org.apache.log4j.ConsoleAppender
   layout class=org.apache.log4j.PatternLayout
   param name=ConversionPattern value=%d{dd MMM  HH:mm:ss}
[%t] %-5p %c - %m%n/
   /layout
   /appender

   appender name=debug-appender class=org.apache.log4j.FileAppender
   param name=file value=debug.log/
   layout class=org.apache.log4j.SimpleLayout/
   /appender

   root
   priority value=debug/
   appender-ref ref=debug-appender/
   /root

I'm not very sure how i can set up the environment, probably need some
advice from experienced users.

Appreciate any help