Hello Denis,
The SiftingAppender uses a "discriminator" to sift events. This
discriminator *can* be based on any part of the logging event and in
particular the logger name.
Here is an example of a possible LoggerBasedDiscriminator:
-------------------------------
package org.example;
public class LoggerBasedDiscriminator extends
AbstractDiscriminator<ILoggingEvent> {
private String key;
@Override
public void start() {
if (OptionHelper.isEmpty(key)) {
addError("The \"Key\" property must be set");
started = false;
} else {
started = true;
}
}
public String getDiscriminatingValue(ILoggingEvent event) {
return event.getLoggerName();
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
-------------------------------
Here is an example configuration for the sifting appender:
<appender name="SIFT"
class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator class="org.example.LoggerBasedDiscriminator ">
<key>task</key>
</discriminator>
<sift>
<appender name="FILE-${task}"
class="ch.qos.logback.core.FileAppender">
<file>${task}.log</file>
<append>false</append>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d [%thread] %level %logger{35} - %msg%n</pattern>
</layout>
</appender>
</sift>
</appender>
As far as I can tell, the above is fits your initial requirements.
However, I have not tested the above which might not even compile.
--
Ceki
On 18.10.2017 08:41, Денис Матвеев wrote:
The MDC does not help when I have several different long-running tasks
in one thread and I just want to immediately separate their logs. It
seems that this is not such a fantastic wish. It is much easier to
separate logical logging flows at once, than to filter them later in
databases. The amount of data is large, logs per day can accumulate
several hundred megabytes. It turns out that we will have to write our
own implementation of such a log.
_______________________________________________
logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user