commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@apache.org>
Subject Re: [logging] setLevel in Jkd14Logger
Date Tue, 13 Apr 2004 06:26:55 GMT
Peter B. West wrote:

> Craig,
>
> I read the notes on configuration, but it seems to me that level 
> setting is not a configuration issues, but a runtime issue.  In my 
> brief experience of 1.4 logging, I found that I could not set the 
> level on a Logger higher than the initial level at creation, but that 
> I could dynamically alter the level to anywhere up to that boundary.  
> (Don't quote me on that - I couldn't find such specific details in the 
> documentation.)  Setting the initial and boundary level is a 
> configuration issue, but what about later modification?
>
> The capacity to dynamically alter the logging level on a given logger 
> seems invaluable to me, especially in a server environment.  It is 
> easy enough to implement a default "do nothing" behaviour for loggers 
> that don't have dynamic level setting.
>
> I would like to think that the configuration for particular loggers 
> could be isolated to the constructors, and that all run-time activity 
> could be amalgamated under the wrapper.
>
Building something like this into the commons-logging wrappers for 
general use would be problematic technically, even if we were willing to 
do so (and I'm certainly -1 on it), for it would presume that all of the 
underlying logging implementations share the notion of dynamically 
changeable log levels.

For your own purposes, you might consider providing your own LogFactory 
implementation that returns a specialized Log implementation class 
(perhaps subclassing Jdk14Logger) with a public setLevel method.  
Nothing says you have to use the standard implementation.

Craig


> Craig McClanahan wrote:
>
>> Peter B. West wrote:
>>
>>> SimpleLog has getLevel and setLevel methods, but Jdk14Logger does 
>>> not. The underlying Logger supports these methods, but it seems on 
>>> first inspection that I can only modify the logging level on an 
>>> existing instance by "knowing" that I am running a 1.4 Logger, 
>>> getting the native Logger instance, and setting the level on that.
>>>
>>> Is this the case?  If so, should the Log interface include getLevel 
>>> and setLevel, possibly returning null and false respectively when 
>>> the underlying implementation does not support level setting?
>>>
>> The commons-logger package is designed to be an adapter on the actual 
>> logging calls to the underlying logging implementation, not the 
>> configuration.  It is expected that, if you are using JDK 1.4 
>> logging, then you must use the standard configuration mechanisms for 
>> setting up loggers and logging levels.  Likewise, if you're using 
>> Log4J, you would use a log4j.properties file.
>>
>> The only reason that SimpleLog has a setLevel method is that it, 
>> itself, *is* a simple :-) logging implementation so that you can use 
>> c-l out of the box.  But configuring any sophisticated logging 
>> environment is out of scope for c-l.
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message