RE: Help understanding Log4j basics

2010-11-25 Thread Bender Heri
 I've previously searched the manual and I understand the hierarchy of:
 DEBUG  INFO  WARN  ERROR  FATAL
 However, I'm interested in in learning if there is a way to print ONLY
 one level rather than the target level and all levels above it. Unless
 I've missed it, the manual does not explain if this is possible (or
 how to do it).

In order to print a particular level only you can use LevelFilters which you 
can configure in xml configuration. E.g.

appender name=CONSOLE.OUT class=org.apache.log4j.ConsoleAppender
param name=target value=System.out/
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%d{HH:mm:ss.SSS} (%6r) %-5p 
[%-7t] %F:%L %x - %m%n/
/layout
filter class=org.apache.log4j.varia.LevelRangeFilter
param name=LevelMin value=trace/
param name=LevelMax value=info/
param name=AcceptOnMatch value=false/
/filter
/appender


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



Re: Help understanding Log4j basics

2010-11-23 Thread Christian Grobmeier
 1. How does one start log4j in a webapp? Is having the
 log4j.properties or log4j.xml file in the classpath enough?

Usually yes. You should have log4j itself in the classpath, of course.

 2. How does one stop log4j in a webapp?

Configure it via log4j config, then restart webapp (this reloads configuration)

 3. Is there a way to specify which level of logging, i.e. debug, info,
 error, is printed?

Yes, via the log4j configuration file.
http://logging.apache.org/log4j/1.2/manual.html
(search for configuration)

Cheers,
Christian


 Thanks.

 -Ari

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





-- 
http://www.grobmeier.de

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



Re: Help understanding Log4j basics

2010-11-23 Thread Ari King
 2. How does one stop log4j in a webapp?

 Configure it via log4j config, then restart webapp (this reloads 
 configuration)

After reviewing the manual, as I understand it the way to turn off
logging is by not assigning a log level or assigning a high (error or
fatal) log level. But doesn't that leave open the possibility of
having log messages, albeit of a higher level i.e. error or fatal?

 3. Is there a way to specify which level of logging, i.e. debug, info,
 error, is printed?

 Yes, via the log4j configuration file.
 http://logging.apache.org/log4j/1.2/manual.html
 (search for configuration)

I've previously searched the manual and I understand the hierarchy of:
DEBUG  INFO  WARN  ERROR  FATAL
However, I'm interested in in learning if there is a way to print ONLY
one level rather than the target level and all levels above it. Unless
I've missed it, the manual does not explain if this is possible (or
how to do it).

Best,
Ari

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