Log4J question

  • Thread starter Joona I Palaste
  • Start date
J

Joona I Palaste

Suppose I make my own implementation of org.apache.log4j.Level. Call it
FOOBAR.

Now in the style of the Log4J example configuration file (to be parsed
with PropertyConfigurator):

log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# Print the date in ISO 8601 format
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

# Print only messages of level WARN or above in the package com.foo.
log4j.logger.com.foo=WARN

Can I somehow change the last line to:
log4j.logger.com.foo=FOOBAR

and expect logs from com.foo or its subloggers come at level FOOBAR or
above?
 
R

Ryan Stewart

Joona I Palaste said:
Suppose I make my own implementation of org.apache.log4j.Level. Call it
FOOBAR.

Now in the style of the Log4J example configuration file (to be parsed
with PropertyConfigurator):

log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# Print the date in ISO 8601 format
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

# Print only messages of level WARN or above in the package com.foo.
log4j.logger.com.foo=WARN

Can I somehow change the last line to:
log4j.logger.com.foo=FOOBAR

and expect logs from com.foo or its subloggers come at level FOOBAR or
above?
I think for custom levels you're supposed to use:
log4j.logger.com.foo=level#com.foo.FooBar

where com.foo.FooBar is the full class name. Never tried it myself though.
 
R

Ryan Stewart

Ryan Stewart said:
Joona I Palaste said:
Suppose I make my own implementation of org.apache.log4j.Level. Call it
FOOBAR.

Now in the style of the Log4J example configuration file (to be parsed
with PropertyConfigurator):

log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# Print the date in ISO 8601 format
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

# Print only messages of level WARN or above in the package com.foo.
log4j.logger.com.foo=WARN

Can I somehow change the last line to:
log4j.logger.com.foo=FOOBAR

and expect logs from com.foo or its subloggers come at level FOOBAR or
above?
I think for custom levels you're supposed to use:
log4j.logger.com.foo=level#com.foo.FooBar

where com.foo.FooBar is the full class name. Never tried it myself though.
Woops, sorry. I went off on a tangent in my own mind and ended up answering the
wrong question. That's obviously how you use custom *loggers*. I'm not sure
about the level thing. Have you tried it yet? What were your results?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top