[logback-user] Are special charcters allowed in logger configurations?

Noman Amir Jamil n.amir.jamil at gmail.com
Wed Jan 4 12:56:16 CET 2012


Thanks for the reply Tony, I am glad to know it works and the issue is not
with the square brackets then.

Could it be my appender/logger configuration then? The situation is, under
normal configuration [tomcat's juli logging], my my webapps
writes separately to catalina.log and localhost.log. But when I configure
logback, the catalina.log only has tomcat logging and all my webapps
loggings ends up in localhost.log. Below is my logback.xml:

========================================================
<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener"/>

<appender name="CONSOLE"
class="org.apache.juli.logging.ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} %-5level {%thread} [%logger{20}] :
%msg%n</pattern>
</encoder>
</appender>

<appender name="FILE-CATALINA"
class="org.apache.juli.logging.ch.qos.logback.core.rolling.RollingFileAppender">
<file>${catalina.base}/logs/catalina.log</file>
<append>true</append>
<encoder>
<charset>utf-8</charset>
<pattern>%date{"MMM dd, yyyy HH:mm:ss a"} %C %n%level: %msg%n</pattern>
</encoder>
<rollingPolicy
class="org.apache.juli.logging.ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${catalina.base}/logs/catalina-%d{yyyyMMdd}-%i.log.zip</fileNamePattern>
<maxHistory>1<!-- days --></maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="org.apache.juli.logging.ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10KB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>

<appender name="FILE-LOCALHOST"
class="org.apache.juli.logging.ch.qos.logback.core.rolling.RollingFileAppender">
<file>${catalina.base}/logs/localhost.log</file>
<append>true</append>
<encoder>
<charset>utf-8</charset>
<pattern>%date{"MMM dd, yyyy HH:mm:ss a"} %c %n%level : %msg%n</pattern>
<!-- <pattern>%d{MMM dd, yyyy ;HH:mm:ss} %level : %msg%n</pattern> -->
</encoder>
<rollingPolicy
class="org.apache.juli.logging.ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${catalina.base}/logs/localhost-%d{yyyyMMdd}-%i.log.zip</fileNamePattern>
<maxHistory>60<!-- days --></maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="org.apache.juli.logging.ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10KB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>

<logger name="org.apache.catalina" level="INFO" additivity="false">
<appender-ref ref="FILE-CATALINA" />
</logger>
 <logger name="org.apache.catalina.session" level="INFO" additivity="false">
<appender-ref ref="FILE-CATALINA" />
</logger>
 <logger name="org.apache.catalina.core" level="INFO" additivity="false">
<appender-ref ref="FILE-CATALINA" />
</logger>
 <logger
name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost]"
level="INFO" additivity="false">
<appender-ref ref="FILE-CATALINA" />
<appender-ref ref="FILE-LOCALHOST" />
</logger>

<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>

</configuration>

========================================================

This is on Windows Server 2008, Tomcat6.

Can you suggest anything to rectify this?
Thanks

Noman A.

On Wed, Jan 4, 2012 at 3:38 PM, Tony Trinh <tony19 at gmail.com> wrote:

> I just tried logback.xml with square brackets in the logger name and
> didn't see any apparent problems (the logger printed log statements as
> expected).
>
> -Tony
>
> On Wed, Jan 4, 2012 at 4:42 AM, Noman Amir Jamil <n.amir.jamil at gmail.com>wrote:
>
>> Hi,
>>
>> I would like to know if the following issue is resolved in logback, it
>> was previously encountered in log4j:
>>
>> "there are known issues with using this naming convention (with square
>> brackets) in log4j XML based configuration files"
>>
>> I am using a similar configuration with square brackets:
>>
>> logger
>> name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost]"
>> level="INFO" additivity="false">
>>
>> But it appears that the portion after ContainerBase is being ignored or
>> not processed.
>>
>> I would really appreciate any help on this.
>>
>> Thanks
>> Noman A.
>>
>> _______________________________________________
>> Logback-user mailing list
>> Logback-user at qos.ch
>> http://mailman.qos.ch/mailman/listinfo/logback-user
>>
>
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120104/fd5ae604/attachment.html>


More information about the Logback-user mailing list