logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Schuetze <schue...@geoinform.fh-mainz.de>
Subject Re: Need advice for class logging
Date Mon, 05 Dec 2005 11:33:17 GMT
Hi Curt Arnold,
First of all, thanks for reply on my mail.

Curt Arnold schrieb:
> On Dec 2, 2005, at 11:27 AM, Rainer Schuetze wrote:
>> Hi,
>> I tried to log different class with e.g. the level "info". But the
>> logger logs on the basic level. I've no idea what I'm doing wrong. I
>> need somebodies help.
> I do not understand what you mean by "basic" level.  Could you  describe 
> or provide examples what behavior that you are seeing and  describe what 
> you expected

I mean with "basic" level the level of the root. But I think you are 
mentioning something interesting below

>> I've defined the logger as a private static variable in the header  file.
>> In my CPP file I get the instance of my logger as follow:
>> log4cxx::LoggerPtr XMLParser::logger =
>> log4cxx::LoggerPtr(log4cxx::Logger::getLogger("limez.xml.XMLParser"));
> Looks okay to me.

The funny think is on this part is, if I define the logger within the 
class as not static, the defined logging (e.g. info) level and above are 

>> I'm using the DOMConfigurator to configure and defined within the XML
>> file the logger as follow:
>>   <logger name="limez">
>>     <level value="info" />
>>   </logger>
>>   <root>
>>     <priority value ="debug" />
>>     <appender-ref ref="stdout" />
>>   </root>
>> Regards
>> Rainer
> I read this as a fragment of a configuration file that instructs  log4j 
> that all log request directed to "limez" or child loggers with  a level 
> of info or higher and log requests not directed to "limez" or  child 
> loggers with a level of debug of higher will pass the level  filter.  If 
> a request passes the level filter, it will be processed  by the appender 
> definition with id="stdout" which must be defined  elsewhere in the 
> configuration file.
I posted just an fragment of the configuration file. You read the 
configuration file right. The log is directed to "limez" or its 
children. But as I mentioned above, the logger logs only to the root 
level and seams to ignore the level of 'limez'.
But what I don't understand is when I define the logger as a private 
variable within the class, e.g.

this->logger = log4cxx::LoggerPtr( log4cxx::Logger:: 
getLogger("limez.xml.XMLParser") );

the logger works fine and logs the level 'info' or higher. I thought the 
idea of using the logger should be done on the static way. Might this be 
an Bug or did I miss implement the logging,


Here is the full XML-File which I use to log:

<log4j:configuration debug="true" 
    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
     <layout class="org.apache.log4j.SimpleLayout"/>

   <logger name="limez">
     <level value="info" />

     <priority value="DEBUG"/>
     <appender-ref ref="stdout"/>

View raw message