Reputation: 2801
In my logback config file, I have the following appender that work :
<appender name="thread_SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator class="[...]"/>
<sift>
<appender name="FILE-${threadName}" class="ch.qos.logback.core.FileAppender">
<file>[...]/${bySecond}/${threadName}.log</file>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date %level %logger{0} - %msg%n</pattern>
</layout>
</appender>
</sift>
</appender>
The file are created correctly. If I replace FileAppender by RollingFileAppender, nothing is created. Why? How can I make it work>
The threadName is set by the discriminator.
Upvotes: 3
Views: 3810
Reputation: 21
Seems the property ${bySecond}
or any one else is lost inside sift > appender
tag.
ERROR in ch.qos.logback.core.joran.spi.Interpreter@23:97 - no applicable
action for [property], current pattern is [[configuration][appender][property]]
[...]/bySecond_IS_UNDEFINED/main.log
Upvotes: 2
Reputation: 27450
The OnConsoleStatusListener is your friend. Just add
<configuration>
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
.. remainder of your config file
</configuration>
at the beginning of your configuration file to see the errors generated by SiftingAppender
.
Upvotes: 5
Reputation: 2801
There was an error in package name. It seem error under the tag sift are silently ignore. To test, I need to copy the appender outside the sift tag, make sure I have no error and copy it back.
Upvotes: 0
Reputation: 7064
In complement to my comment, you can verify that a file is correctly created using this appender in your sift appender (taken from the Logback Tutorial about RollingFileAppender configuration).
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>test.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>tests.%i.log.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>3</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>5MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
Upvotes: -1