logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <c...@qos.ch>
Subject Re: Proposal: Setting Level with BasicConfigurator
Date Wed, 30 Jan 2002 07:45:25 GMT
Simon,

The BasicConfigurator is just a way to get log4j to print something
very quickly. For more flexibility you can configure log4j
programmatically or use configuration files. 

To set the level of the root logger to INFO level just do:

   Logger.getRootLogger().setLevel(Level.INFO);

I feel very bad about rejecting your contribution but I am afraid that
is the right thing to do. 

At 08:10 28.01.2002 -0500, you wrote:
>Proposal:
>
>What: Making the Log-Level of the root category manageable by the BasicConfigurator
>
>How: Adding the methods 
>     configure(Level level)  
>     and 
>     configure(Appender appender, Level level)
>
>Why: In some cases it would be nice to turn of low level (for instance DEBUG) loggings

>     without or before using a config file. Enableing this in the BasicConfigurator is

>     more convenient for the Developer as going over the root Logger itself
>     Example 1: A small (Test?) project, where using a conf file is to much overhead
>     Example 2: (A real case that brought me to change the code)
>        Imaging a project that uses a XML Config file to config the names and pathes of
>        all the needed files (And of course some other stuff). One of these files is the
>        Log4J conf file. Now this project uses some XML-Helper classes to read the
>        programs config file which are also using Log4J logging. 
>        This leads to the case, that when we use only the BasicConfigurator at the 
>        beginning, we get a lot of "debug" log statments out of the 
>        "read-the-xml-configfile-helper-classes" until we have extracted the path 
>        of the Log4J conf file so we can use it. This is pretty annoying, because I 
>        allready know my helper-classes are working and don't want to see the debug
>        and info loggings.

As a general rule, helper classes, libraries, non-top level components
should not attempt to configure log4j. Configuring log4j is the
responsibility of the end-user or generally the application
deployer. Whenever possible, a library should not try to configure
logging but leave it to the deployer. After all, logging output is
useful only if someone will take the time to look at them. If the
end-user wishes to log then she should control the logging
configuration. Nevertheless, it is helpful if the library developper
provides documentation on logging, preferably with working examples.



--
Ceki Gülcü



--
To unsubscribe, e-mail:   <mailto:log4j-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>


Mime
View raw message