[logback-user] Dynamically attaching the loggers to appenders

Pradnya Gawade pradnya.gawade7 at gmail.com
Fri Dec 3 00:27:26 CET 2010


Why I don't create a separate logger for each package/class is because
each special format is is associated with lot of sub packages, clasess
and it will create a long list of loggers.



On Thu, Dec 2, 2010 at 6:16 PM, Pradnya Gawade
<pradnya.gawade7 at gmail.com> wrote:
> Hi, I am having the issue described below, sorry for the long post but
> I think that is required to better explain the problem.
>
> I want to separate out the logs in such a way that some special
> packages, classes needs to go in specific log format and rest of the
> logs will go in default format. I have created the multiple file,
> Syslog appenders with all the required formats. But I am having
> difficulty configuring in such a way that the log messages from
> packages other than my special packages will go with the default
> appender. Initially my idea was to map the basic outer package to all
> the special appenders as well as to default appender, create a filter
> for each special appender so it will only take the specific package
> logs only. But the problem is that default appender takes all the log
> messages. I can again implement a filter for the default appender so
> it will take all the excluded log s only but probably it it will be
> lot of processing unnecessarily, evaluating the same criteria again
> and again for each logging request. Is there any way so I can
> intercept each logging request such that I can decide which appender I
> need this logger to map to (by implementing some java routine), put
> the result in MDC context and make use of that result variable in the
> configuration to associate the required appender (using if-else
> syntax)? I saw that Sifting appender might be helpful in this scenario
> but I don't know where I can put my processing logic to decide which
> appender I want the logger to associate to so I can use its result as
> discrminator. Any ideas?
>
>
> Thanks,
> Pradnya
>


More information about the Logback-user mailing list