[logback-user] separate task log files (slf4j + logback)

Oleksandr Gavenko gavenkoa at gmail.com
Wed Oct 18 09:20:25 CEST 2017


On Wed, Oct 18, 2017 at 9:41 AM, Денис Матвеев <denism78 at gmail.com> 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.

If they different they should use different packages for logger name
and you can separate based on base package.

I can't imaging that regular Java app uses single thread for different
task simultaneously. Unless you use some cooperative threading
framework (Akka?) or some obscure setup.

I see you lazy to make two calls MDC.put and MDC.remove.

It can be that you are looking for dumping of app data instead of
logging app events. In that case just open as many files for write as
you wish. You don't need Logback for such task.

> 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.
>
You can separate logs in filtering/routing software like I wrote:
Flume, Fluentd, Logstash, Kafka, or whatever popular today. Direct
events to intermediate agent that able to split and transform logging
events.

Of course write to local file is most reliable way to save data as 3rd
party network service can be unavailable...


More information about the logback-user mailing list