Eric,

If you are using log4j, then you can configure it with a properties file. As
an example (minus some of my project specific settings), here is a simple
log4j configuration file that establishes a rolling log file. Notice near
the bottom where I set the struts and commons packages to the WARN log
level. This suppresses the INFO and DEBUG log messages for these packages.

# Usage: Specifies the configuration properties for log4j.
#
# Notes: This properties file should be placed somewhere
#        inside the WEB-INF/classes directory.

# Create two appenders, one called stdout and the other called rolling
log4j.rootLogger=WARN, stdout, rolling

# Configure the stdout appender to go to the Console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender

#  Configure the stdout appender to use the PatternLayout
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

# Configure the rolling appender to be a RollingFileAppender
log4j.appender.rolling=org.apache.log4j.RollingFileAppender

# Configure the name of the logout for the rolling appender
# For Tomcat:
# log4j.appender.rolling.File=../logs/app-rolling.log
# For Weblogic:
log4j.appender.rolling.File=/logs/app-rolling.log

# Set up the maximum size of the rolling log file
log4j.appender.rolling.MaxFileSize=5120KB

# Keep two backup files of the rolling appender
log4j.appender.rolling.MaxBackupIndex=2

# Configure the Layout pattern and conversion pattern for the rolling
appender
log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
log4j.appender.rolling.layout.ConversionPattern=%d{ISO8601} - %p %c - %m%n

# Set Struts/Commons log level
log4j.logger.org.apache.struts=WARN
log4j.logger.org.apache.commons=WARN

-----------

Of course, you have to configure your installation to read the properties
file. The simplest way is to include it inside the war at the root of your
class package structure where it gets picked up by default. However, you can
explicitly point to a properties file outside the war using command line
arguments to the JVM startup command for your servlet container. This is how
we have it setup for our production webapps so that we can reconfigure the
logging options without having to redeploy the war file again. See the log4j
docs for more information:

http://tinyurl.com/3hlrq

Hope this helps, Van

Mike "Van" Riper
Silicon Valley Struts User Group
http://www.baychi.org/bof/struts/

> -----Original Message-----
> From: Eric Hodges [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 23, 2004 12:28 PM
> To: Struts Users Mailing List
> Subject: RE: Questions about debug and info messages
> 
> 
> Thanks for the advice, but I'm using log4j.  The API doc you 
> to which you
> linked doesn't offer much help.  I hacked a solution by 
> setting the message
> level on the struts logger to "warning" in one of my 
> servlet's init method,
> but surely there's a configuration setting (like a parameter 
> to the Action
> servlet?) that will set the message level.
> 
> 
> 
> -----Original Message-----
> From: Pady Srinivasan [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 23, 2004 8:21 AM
> To: Struts Users Mailing List
> Subject: RE: Questions about debug and info messages
> 
> 
> 
> 
> If you are using  JDK 1.4 and not using log4j, then look in
> JAVA_HOME/jre/lib for a file called logging.properties. Set 
> the .level to
> OFF. The levels in descending order are: SEVERE (highest 
> value) WARNING INFO
> CONFIG FINE FINER FINEST (lowest value) In addition there is 
> a level OFF
> that can be used to turn off logging, and a level ALL that 
> can be used to
> enable logging of all messages.
> 
> I haven't used log4j. Here is the struts docs:
> 
> http://jakarta.apache.org/commons/logging/api/org/apache/commo
> ns/logging/pac
> kage-summary.html#package_description
> 
> 
> 
> Thanks
>  
> -- pady
> [EMAIL PROTECTED]
>  
> 
> -----Original Message-----
> From: Eric Hodges [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, March 23, 2004 10:36 AM
> To: Struts Users Mailing List (E-mail)
> Subject: Questions about debug and info messages
> 
> We have a torrent of debug and info messages coming out of 
> struts.  I can't
> find any documentation about how to turn them off.  Two questions:
> 
> 1. How do I turn off debug and info level messages?
> 2. Where is that documented?
> 
> Thanks,
> Eric Hodges

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

Reply via email to