You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Peter B. West" <pb...@tpg.com.au> on 2004/04/12 03:48:40 UTC

[logging] setLevel in Jkd14Logger

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?

-- 
Peter B. West <http://www.powerup.com.au/~pbwest/resume.html>

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


Re: [logging] setLevel in Jkd14Logger

Posted by Craig McClanahan <cr...@apache.org>.
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


Re: [logging] setLevel in Jkd14Logger

Posted by "Peter B. West" <pb...@tpg.com.au>.
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.

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.

-- 
Peter B. West <http://www.powerup.com.au/~pbwest/resume.html>

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


Re: [logging] setLevel in Jkd14Logger

Posted by Craig McClanahan <cr...@apache.org>.
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.

Craig


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