logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: log4j 2.0 - About StatusLogger logging level and console output
Date Sun, 03 Aug 2014 05:57:25 GMT
What he may really want is a way to register the console listener earlier - via a system property.

Ralph

On Aug 1, 2014, at 12:24 AM, Remko Popma <remko.popma@gmail.com> wrote:

> Ok. Take a look at the system properties section of the Configuration manual page. There
seem to be two settings. I'm not sure which to use: Log4jDefaultStatusLevel or log4j2.StatusLogger.level.

> 
> Sent from my iPhone
> 
>> On 2014/08/01, at 16:15, Marco Cosentino <cosentino.ma@gmail.com> wrote:
>> 
>> Hi Remko,
>> thanks for the reply.
>> I'd still like something which can be enabled through system preoperties and logs
at very early stages, for example, where the config is read from.
>> 
>> Marco.
>> 
>>> On 08/01/2014 12:04 AM, Remko Popma wrote:
>>> All you need to do is set status="trace" in your log4j2.xml config file.
>>> 
>>> So the beginning of your config looks like this:
>>> <Configuration status="trace" ...
>>> 
>>> Sent from my iPhone
>>> 
>>>> On 2014/08/01, at 1:13, Marco Cosentino <cosentino.ma@gmail.com> wrote:
>>>> 
>>>> Hi,
>>>> I'm trying to get log4j 2.0 debug information printed out in the console
but I couldn't manage to get them.
>>>> In log4j 1.x you would set the system property "log4j.debug".
>>>> 
>>>> I thought that the mechanism was similar in log4j 2.x and apparently it should
be by setting
>>>> log4j2.StatusLogger.level=DEBUG
>>>> 
>>>> Still nothing, so I dug a little bit in the code and found that the StatusLogger
logs its messages either to the listeners (if there's at least one) or to a SimpleLogger (logger)
which is initialized in the constructor (method StatusLogger#logMessage()).
>>>> 
>>>> I found that there was a JMX listener registered so I disabled JMX beans
with
>>>> log4j2.disable.jmx=true
>>>> but still no luck: the messages don't appear in the console.
>>>> 
>>>> I noticed though that the constructor might be the source of the problem:
>>>> 
>>>>   private StatusLogger() {
>>>>       this.logger = new SimpleLogger("StatusLogger", Level.ERROR, false,
true, false, false, Strings.EMPTY, null, PROPS,
>>>>           System.err);
>>>>       this.listenersLevel = Level.toLevel(DEFAULT_STATUS_LEVEL, Level.WARN).intLevel();
>>>>   }
>>>> 
>>>> The SimpleLogger is initialized using level ERROR therefore the isEnabled
implementation in StatusLogger returns the logging level of this.logger which is always ERROR
even if I wanted DEBUG.
>>>> 
>>>> Would it make sense to use DEFAULT_STATUS_LEVEL to actually set the level
into the SimpleLogger constructor?
>>>> Why is it so hard to get debug messages showing up in the console (I mean
disable JMX and set the property to DEBUG)?
>>>> 
>>>> Best,
>>>> Marco Cosentino
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 


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


Mime
View raw message