Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what does log4j info level mean

 
Archana Annamaneni
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,

I have configured my log4j propertis file as following

log4j.rootLogger=info, R

log4j.appender.R=org.apache.log4j.FileAppender
log4j.appender.R.File=/usr/local/jakarta-tomcat-4.1.30/logs/xmlgateway/xmlgatewaylog.log

log4j.appender.R.layout=org.apache.log4j.SimpleLayout

And in one my Struts Action classes
I included some
log.info("xxxxxx")statements.

But the log file has these other info messages also , how do i avoid these?

INFO - Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
INFO - Initializing, config='org.apache.struts.action.ActionResources', returnNull=true

what should i do to include only my own log statemens.

Thanks
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You set up your root logger at info level using "R" appender; this means that all log4j logging will go that appender including third party products.

You can do the following

1. put a logger in your properties file for the struts package such as "log4j.logger.org.apache.struts"

2. with the struts logger using a different appender and/or set to a different level

# only warnings or higher logging to a different appender (you would
# need to define that different appender)
log4j.logger.org.apache.struts=warn,STRUTS

# same appender, higher level
log4j.logger.org.apache.struts=warn,R

3. and you need to turn off additivity on the struts logging
log4j.additivity.org.apache.struts=false

The additivity part says for this logger, don't log to appenders attached to any loggers up the hierarchy (root logger in this case). This is important to keep from getting duplicate messages.

If you're just getting struts set up in your project it is good to keep the struts logging turned on (but to a different appender so that it doesn't clutter up your logging) so you can see what might be going wrong with the struts setup.

Check out the log4j manual for syntax and more explanation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic