Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
1.0.6
-
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
Description
RollingFileAppender is not worked inside siftingAppender when using logback-access!!!
logback-access.xml:
<configuration>
<property scope="context" name="ACCESS_NORMAL_PATTERN" value="%t
|%9reqCookie
{userid}|%20(%remoteIP:%remotePort)|%5b|%3s|%U|%reqParameter|%responseContentSimple
{1,LHB}" />
<appender name="access_file" class="ch.qos.logback.access.sift.SiftingAppender">
<Discriminator>
<Key>launchName2</Key>
<FieldName>LAUNCH_NAME2</FieldName>
<DefaultValue>unknown</DefaultValue>
</Discriminator>
<sift>
<appender name="ROLLING-${launchName2}" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>logs/${launchName2}/rolling.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>logs/${launchName2}/rolling.%i.log</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>300</MaxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>20MB</MaxFileSize>
</triggeringPolicy>
<encoder>
<Pattern>${NORMAL_PATTERN}</Pattern>
</encoder>
</appender>
</sift>
</appender>
<appender-ref ref="access_file" />
</configuration>
if I use the RollingFileAppender inside the siftingAppender, it can create the "access.log" file only,but the file is empty,nothing is written.
However,if I change the RollingFileAppender to FileAppender, like:
<appender name="SIFTING" class="ch.qos.logback.access.sift.SiftingAppender">
<Discriminator>
<Key>launchName</Key>
<FieldName>LAUNCH_NAME2</FieldName>
<DefaultValue>unknown</DefaultValue>
</Discriminator>
<sift>
<appender name="${launchName}" class="ch.qos.logback.core.FileAppender">
<File>logs/${launchName}.log</File>
<layout class="ch.qos.logback.access.PatternLayout">
<Pattern>${ACCESS_NORMAL_PATTERN}</Pattern>
</layout>
</appender>
</sift>
</appender>
the logback-access works well.
SiftingAppender can create different FileAppender for each ${launchName}.
These appenders using in logback-classic are perfect, I don't know why they can't work in logback-access.
Actually, "ch.qos.logback.access.sift.SiftingAppender" and "ch.qos.logback.classic.sift.SiftingAppender"
extend "ch.qos.logback.core.sift.SiftingAppenderBase". They only differ on Discriminator and thus
should work similarly.
and the RollingFileAppender is in the ch.qos.logback.core package, the ways to use in logback-classic and logback-access are the same.
So, I can not tell where is the problem. For help!!Unable to render embedded object: File (emergency) not found.!! I love logback!