You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Kendal Montgomery <mo...@armadapower.com> on 2015/04/09 21:42:54 UTC
log4cxx configuration...
I'm curious if anyone else has tried or has issues with configuring
logging levels for specific loggers in a log4cxx.xml file? I have the
following log4cxx.xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Output the log message to system console.
-->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p
[%t] %c{2} - %m%n" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="CONSOLE"/>
</root>
<!--
<category name="Outstation.Messaging">
<priority value ="DEBUG" />
</category>
-->
<logger name="Outstation.Messaging">
<level value="DEBUG" />
</logger>
<logger name="Outstation.Messaging.TestHandler">
<level value="DEBUG" />
</logger>
</log4j:configuration>
I have a logger configured in my code with the name
"Outstation.Messaging.TestHandler". I'm used to using log4j and if I
configured it this way, all messages that did not have a specific
priority set would be logged at level INFO, but with this configuration,
anything with Outstation.Messaging or lower should be logged at level
DEBUG, and specifically the logger i have defined in my code that I
mention above should log DEBUG level messages to the console. However,
this is not happening; I get nothing but INFO all around. If I change
the root logger level to DEBUG, I get everything logging at DEBUG level,
but finer grained logger configuration doesn't seem to work. Does
log4cxx not use hierarchical logger configuration separated by a period
like java?
Any ideas? I'm using 0.10.0.
Thanks in advance.
Kendal.
Re: log4cxx configuration...
Posted by Kendal Montgomery <mo...@armadapower.com>.
Thank you for the suggestions. I figured out my problem by turning on
the debugging. I was trying to figure out how to do the equivalent of
starting the a JVM with -DLOG4J.DEBUG=true, and I totally forgot you
could add that to the configuration file. I had a very silly type-o.
Thanks once again for the help!
Kendal
On 4/9/15 6:18 PM, Jacob L. Anawalt wrote:
> On 4/9/2015 1:42 PM, Kendal Montgomery wrote:
>> I'm curious if anyone else has tried or has issues with configuring
>> logging
>> levels for specific loggers in a log4cxx.xml file?
>
> I use an xml configuration file and at times configure different
> levels for specific loggers in the hierarchy.
>
>> I have a logger configured in my code with the name
>> "Outstation.Messaging.TestHandler".
>
> Like this?
>
> #include <log4cxx/logger.h>
>
> int main(int argc, char* argv[]) {
> log4cxx::LoggerPtr
> logger(log4cxx::Logger::getLogger("Outstation.Messaging.TestHandler"));
> LOG4CXX_DEBUG(logger,"Testing");
>
> return 0;
> }
>
> It appeared to work for me using the log4cxx.xml you had in the email.
>
> 2015-04-09 16:05:48,057 DEBUG [0xb7227710] Messaging.TestHandler -
> Testing
>
>> Does log4cxx not use hierarchical logger configuration separated by a
>> period like java?
>>
>
> It does.
>
>> Any ideas? I'm using 0.10.0.
>>
>
> Same. Maybe you're not using the configuration you think you are. Try
> enabling debug in the configuration or tweaking the ConversionPattern
> to make sure it's the source of your configuration. Also have you
> verified this with a small program?
>
> <log4j:configuration debug="true"
> xmlns:log4j="http://jakarta.apache.org/log4j/">
>
Re: log4cxx configuration...
Posted by "Jacob L. Anawalt" <ja...@geckosoftware.com>.
On 4/9/2015 1:42 PM, Kendal Montgomery wrote:
> I'm curious if anyone else has tried or has issues with configuring logging
> levels for specific loggers in a log4cxx.xml file?
I use an xml configuration file and at times configure different levels for
specific loggers in the hierarchy.
> I have a logger configured in my code with the name
> "Outstation.Messaging.TestHandler".
Like this?
#include <log4cxx/logger.h>
int main(int argc, char* argv[]) {
log4cxx::LoggerPtr
logger(log4cxx::Logger::getLogger("Outstation.Messaging.TestHandler"));
LOG4CXX_DEBUG(logger,"Testing");
return 0;
}
It appeared to work for me using the log4cxx.xml you had in the email.
2015-04-09 16:05:48,057 DEBUG [0xb7227710] Messaging.TestHandler - Testing
> Does log4cxx not use hierarchical logger configuration separated by a
> period like java?
>
It does.
> Any ideas? I'm using 0.10.0.
>
Same. Maybe you're not using the configuration you think you are. Try enabling
debug in the configuration or tweaking the ConversionPattern to make sure it's
the source of your configuration. Also have you verified this with a small program?
<log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/">
--
Jacob Anawalt
Gecko Software, Inc.
janawalt@geckosoftware.com
435-752-8026