You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by beeky <st...@marine.rutgers.edu> on 2009/03/27 15:15:34 UTC

turning off logging for Tomcat 5.5.27 components

How do I turn off logging from Tomcat 5.5.27 components that I don't care
about. I see a lot of the following in my applications log file:

DEBUG SmapUtil.java.copyConstantPool():446 52 copying 2 bytes

I'm sure this is a log4j configuration issue but I can't figure it out.  My
app has a log4j config file and Tomcat has its own config file but these
Tomcat messages are appearing in the application log file

Can someone enlighten me as to how to turn off these messages or send them
where they belong? 

Thanks,
beeky
-- 
View this message in context: http://www.nabble.com/turning-off-logging-for-Tomcat-5.5.27-components-tp22742535p22742535.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: turning off logging for Tomcat 5.5.27 components

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Beeky,

On 3/27/2009 1:41 PM, beeky wrote:
> Christopher,
> Thanks for the reply, unfortunately I did not understand much of it.  Can I
> ask some questions about what you said?

Absolutely.

>> log4j.rootLogger=ERROR, stdout, TOMCAT
>> This should only allow ERROR or higher messages to be logged, unless
>> another logger has explicitly set a lower log level to be logged (and
>> that logger is being used). That does not appear to be the case, here.
> 
> Are you saying the line should be: 
>  log4j.rootLogger=ERROR

No, the rootLogger line indicates the default log level (that's the
"ERORR" part) plus the default appenders (that's the "stdout,TOMCAT"
part). You don't want to change either of these.

In log4j, a logger is a named entity that you can send log messages to.
An appender is something that actually writes to a destination such as a
file, database, console, etc. The combination of logger + appender
allows you to create very nuanced configurations.

>> log4j.rootCategory=debug, OBIS
>> This is likely to be the source of the problem: you have defined the
>> root logger (rootCategory is deprecated in favor of rootLogger) to have
>> a log level of DEBUG. This will affect any log messages emitted by your
>> application.
>
> I want my application to emit debug messages.  Is there a way to do this
> that does not involve setting the category to DEBUG?

Not really. I suppose you could set the rootLogger to ERROR and then
override this for your own classes. Something like this:

log4j.rootLogger=ERROR, OBIS

...
log4j.appender.OBIS.threshold=DEBUG
...

log4j.logger.your.package.goes.here=DEBUG


This should block messages lower than ERROR for all loggers except those
under the "your.package.goes.here" package, which will log at the DEBUG
level. If you have "com.mycompany" as the prefix for all your loggers
(which are usually named after your class names), then you can simply do
this:

log4j.logger.com.mycompany=DEBUG

See this page for tons of information:
http://logging.apache.org/log4j/1.2/manual.html. You can skip all the
code examples and look at the log4j.properties examples.

>> SmapUtil is in the org.apache.jasper.compiler package, so you need to
>> add configuration for that. It looks like you already have one:
>> log4j.logger.org.apache.jasper.compiler=ERROR
>
> This is the basic problem, this does not stop jasper logging.  Does the fact
> that Jasper is logging to the application log file indicate that this line
> should be something different?

I'm not entirely sure. Your configuration looks good as long as your
config file is really called log4j.properties.

Do you include log4j.jar in your web application's WEB-INF/lib
directory? Do you manually load the log4j.properties file anywhere in
your code? I'm a little unclear as to how Tomcat works when log4j is
being used both for the container as well as for the webapp.

Try updating your configuration to add another appender, just to test to
see that your configuration is actually being read:

log4j.rootLogger=ERROR, testing

log4j.appender.testing=org.apache.log4j.FileAppender
log4j.appender.testing.File=C:/Program Files/Apache Software
Foundation/apache-tomcat-5.5.27/webapps/OBIS1.2/OBISLog/test.log

Then restart the entire Tomcat (not just your webapp, just in case).

If the test.log file appears in the appropriate directory, then log4j
/is/ loading your configuration from the file you think it is. If that
log file is not created, then we need to look at some other options.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAknNJxcACgkQ9CaO5/Lv0PBDCACcD0xL4aHrxvK3qxrlZKT0GO2B
WlYAoL0o0HKTzEwSFSw6MMzQTDoGj19A
=LNEm
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: turning off logging for Tomcat 5.5.27 components

Posted by beeky <st...@marine.rutgers.edu>.
Christopher,
Thanks for the reply, unfortunately I did not understand much of it.  Can I
ask some questions about what you said?

> log4j.rootLogger=ERROR, stdout, TOMCAT
>This should only allow ERROR or higher messages to be logged, unless
>another logger has explicitly set a lower log level to be logged (and
>that logger is being used). That does not appear to be the case, here.

Are you saying the line should be: 
 log4j.rootLogger=ERROR

> log4j.rootCategory=debug, OBIS
>This is likely to be the source of the problem: you have defined the
>root logger (rootCategory is deprecated in favor of rootLogger) to have
>a log level of DEBUG. This will affect any log messages emitted by your
>application.
I want my application to emit debug messages.  Is there a way to do this
that does not involve setting the category to DEBUG?


>SmapUtil is in the org.apache.jasper.compiler package, so you need to
>add configuration for that. It looks like you already have one:
> log4j.logger.org.apache.jasper.compiler=ERROR
This is the basic problem, this does not stop jasper logging.  Does the fact
that Jasper is logging to the application log file indicate that this line
should be something different?

My config files are called log4j.properties. 

If you can, please elaborate on your answers.  I'm sure you are telling me
how to solve the problem I just don't understand.

Thanks,
-=beeky



On 3/27/2009 11:13 AM, beeky wrote:
> -------log4j.config in <catalina_home>/common/classes----------
> log4j.rootLogger=ERROR, stdout, TOMCAT

This should only allow ERROR or higher messages to be logged, unless
another logger has explicitly set a lower log level to be logged (and
that logger is being used). That does not appear to be the case, here.

> ----------- log4j.config in the applications WEB-INF dir
> --------------------
> 
> log4j.rootCategory=debug, OBIS

This is likely to be the source of the problem: you have defined the
root logger (rootCategory is deprecated in favor of rootLogger) to have
a log level of DEBUG. This will affect any log messages emitted by your
application.

Note that certain loggers have been silenced wrt DEBUG messages:

> # Suppress the tomcat logging whilst DEBUG is switched on
> log4j.logger.org.apache.catalina.core=ERROR
> log4j.logger.org.apache.catalina.session=ERROR
> log4j.logger.org.apache.jasper.compiler=ERROR

... and others have been allowed to spew everything:

> # Spring logging
> #log4j.logger.org.springframework=TRACE

SmapUtil is in the org.apache.jasper.compiler package, so you need to
add configuration for that. It looks like you already have one:

> log4j.logger.org.apache.jasper.compiler=ERROR

If your config file really is called log4j.config, then it might not be
properly read: the file is typically called log4j.properties. Are you
manually loading thr configuration file, or are you allowing log4j to
automagically load it for you?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAknM9yAACgkQ9CaO5/Lv0PCNbwCgqXOareEOR6EH35+MoBzDaV2t
UnMAoLagZAH/rvolh4NKL5xGI7S0DDVc
=GBmr
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




-- 
View this message in context: http://www.nabble.com/turning-off-logging-for-Tomcat-5.5.27-components-tp22742535p22745193.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: turning off logging for Tomcat 5.5.27 components

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Beeky,

On 3/27/2009 11:13 AM, beeky wrote:
> -------log4j.config in <catalina_home>/common/classes----------
> log4j.rootLogger=ERROR, stdout, TOMCAT

This should only allow ERROR or higher messages to be logged, unless
another logger has explicitly set a lower log level to be logged (and
that logger is being used). That does not appear to be the case, here.

> ----------- log4j.config in the applications WEB-INF dir --------------------
> 
> log4j.rootCategory=debug, OBIS

This is likely to be the source of the problem: you have defined the
root logger (rootCategory is deprecated in favor of rootLogger) to have
a log level of DEBUG. This will affect any log messages emitted by your
application.

Note that certain loggers have been silenced wrt DEBUG messages:

> # Suppress the tomcat logging whilst DEBUG is switched on
> log4j.logger.org.apache.catalina.core=ERROR
> log4j.logger.org.apache.catalina.session=ERROR
> log4j.logger.org.apache.jasper.compiler=ERROR

... and others have been allowed to spew everything:

> # Spring logging
> #log4j.logger.org.springframework=TRACE

SmapUtil is in the org.apache.jasper.compiler package, so you need to
add configuration for that. It looks like you already have one:

> log4j.logger.org.apache.jasper.compiler=ERROR

If your config file really is called log4j.config, then it might not be
properly read: the file is typically called log4j.properties. Are you
manually loading thr configuration file, or are you allowing log4j to
automagically load it for you?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAknM9yAACgkQ9CaO5/Lv0PCNbwCgqXOareEOR6EH35+MoBzDaV2t
UnMAoLagZAH/rvolh4NKL5xGI7S0DDVc
=GBmr
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: turning off logging for Tomcat 5.5.27 components

Posted by beeky <st...@marine.rutgers.edu>.
Charles,
Thanks for taking the time to look at my problem.  log4J.config files follow
immediately.

-=beeky

-------log4j.config in <catalina_home>/common/classes----------
log4j.rootLogger=ERROR, stdout, TOMCAT

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss:SSS} -
{%p} %c{2} Thread [%t]; %x %m%n

log4j.appender.TOMCAT=org.apache.log4j.DailyRollingFileAppender
log4j.appender.TOMCAT.File=${catalina.home}/logs/tomcat.log
log4j.appender.TOMCAT.DatePattern='.'yyyy-MM-dd
log4j.appender.TOMCAT.layout=org.apache.log4j.PatternLayout
log4j.appender.TOMCAT.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss:SSS} -
{%p} %c{2} Thread [%t]; %x %m%n

----------- log4j.config in the applications WEB-INF dir
--------------------

log4j.rootCategory=debug, OBIS
#log4j.rootCategory=OBIS

# this appender creates a new file for the past day logs
log4j.appender.OBIS=org.apache.log4j.DailyRollingFileAppender
 
# this property makes OBIS.log the 'current' log file for each day                                                                     
log4j.appender.OBIS.File=C:/Program Files/Apache Software
Foundation/apache-tomcat-5.5.27/webapps/OBIS1.2/OBISLog/OBIS.log

# This appender will log messages with priority equal to or higher than this
log4j.appender.OBIS.Threshold=DEBUG

# Suppress the tomcat logging whilst DEBUG is switched on
log4j.logger.org.apache.catalina.core=ERROR
log4j.logger.org.apache.catalina.session=ERROR
log4j.logger.org.apache.jasper.compiler=ERROR

log4j.appender.OBIS.DatePattern='.'yyyy-MM-dd

# this property specifies pattern based layouts
# use any pattern that you prefer
log4j.appender.OBIS.layout=org.apache.log4j.PatternLayout

# Spring logging
#log4j.logger.org.springframework=TRACE

# format: date time as first column
log4j.appender.OBIS.layout.ConversionPattern=[%d{ISO8601}]%p%x %F.%M():%L 
%m%n




-- 
View this message in context: http://www.nabble.com/turning-off-logging-for-Tomcat-5.5.27-components-tp22742535p22743731.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: turning off logging for Tomcat 5.5.27 components

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: beeky [mailto:stafford@marine.rutgers.edu]
> Subject: turning off logging for Tomcat 5.5.27 components
> 
> My app has a log4j config file and Tomcat has its own config file

Post both your log4j config and Tomcat's conf/logging.properties and let's take a look.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org