Log4j configuration: how to suppress internal logs from Log4j?

J

joes

Hello

I am using log4j (v1.2.8) in a tomcat 5 servlet environment.
The log4j output often contains a lot of internal logs about the adding
and removal of loggers, i.e.:

log4j:INFO Returning existing logger [class xy...] in repository
[default].
log4j:INFO Returning existing logger [class xz..] in repository
[default].
log4j:INFO Creating new logger [class xv ...] in repository [default].


How can I suppress that? I tried already with the debug switch of the
configuration, but this didn't help. The "debug" or "configDebug" seems
to getting ignored. Any thoughts?

<configuration xmlns="http://logging.apache.org/" configDebug="false"
debug="false">

....

</configuration>

thanks
Mark Egloff
 
J

joes

I found a way by myself but is currently not so satisfying. I f someone
has another solution i.e. by using the configuration please let me
know.

http://www.mail-archive.com/[email protected]/msg03964.html


Have a look at the class "org.apache.log4j.helpers.LogLog" This class
is used to print out the internal stuff about the internal loggers.
i.e.

class Hierarchy:

LogLog.info(
"Creating new logger ["+name+"] in repository
["+getName()+"].");


class LogLog:

public static void info(String msg) {
if ( !quietMode) {
System.out.println(INFO_PREFIX + msg);
}
}

The LogLog offers a flag "quietMode" which can be set via the method
"setQuietMode(boolean)". As default the flag is turned off.

Unfortunately I haven't found a way to configure it via the
configuration file because it seems not to be implemented. So the way
is either to modify this class and set the "quietMode" to "true" or to
call from any point of your application this static function.

org.apache.log4j.helpers.LogLog.setQuietMode(true);

hope this helps

regards
Mark Egloff
 

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,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top