« Return to Thread: Log4j and Java7/JDBC4.1's CommonDataSource.getParentLogger()

AW: forcing [root] logging - to a separate appender

by José :: Rate this Message:

| View in Thread

do you understand that log4j loggers work in a hierarchy?

        root
        com
        com.axa
        com.axa.ws
        com.axa.ws.spezpla
        com.axa.ws.spezpla.transport

Now
        com.axa.ws.spezpla.SpezplaService.java

        would become a logger named com.axa.ws.spezpla.SpezplaService
        and maybe at various levels in the hierarchy, you have loggers as well.

        now you can add
        log4j.logger.com.axa.ws=INFO, TC_CONS, TC_ROLF, TC_FAP, TC_CHAINSAW
        to block that bad or too fine grained logging events from
        com.axa.ws.spezpla.SpezplaService reach the root logger or any logger above com.axa.ws

by doing so you can intercept unwanted logging events on their way to the top root logger.

hope I got you right.
Josef

-----Ursprüngliche Nachricht-----
Von: Sean A. [mailto:seanga2@...]
Gesendet: Samstag, 7. April 2012 03:23
An: Log4J Users List
Betreff: Re: forcing [root] logging - to a separate appender

On 04/03/2012 11:24 AM, BRUNO MELLONI wrote:

> I support a server that uses log4j.  Of the many applications on it, a few dump their logs as [root] log4j entries.
>
> I would like to setup a category or even separate appender that allows me to control and/or separate these bad log entries.  The problem is that I only want to affect things "just at the root", not every single package in the server.
>
> How would I write such a category or appender configuration?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@...
> For additional commands, e-mail: log4j-user-help@...
>
        You could try implementing you own filter.  Have your class implement
org.apache.log4j.spi.Filter, and implement the decide() method.  That
gets passed a LoggingEvent, and you can look at getThreadName for root.
  From there you'd need to add that filter in your config to whatever
appender you'd like.
        Hope I understand the issue you're having here.  Maybe you could post
some example log entries to clarify the problem.

                --Sean

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@...
For additional commands, e-mail: log4j-user-help@...


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@...
For additional commands, e-mail: log4j-user-help@...

 « Return to Thread: Log4j and Java7/JDBC4.1's CommonDataSource.getParentLogger()