Log4j configuration is cumulative.  One call to configure() does not override another.  Instead, the configurations are combined.  Each time you configure() on a config file that defines an appender, a new one will be added rather than blow away the old one.  Therefore you get duplicate logging as more than one appender is active.

That said, it seems like this behavior was configurable?  Or maybe we merely discussed it a while back since the default behavior is somewhat surprising to users?  Maybe one of the other Log4j developers recalls this discussion and can provide details?


Jake


On Wed, 28 Jul 2010 03:17:25 -0700 (PDT)
 mokader <moka...@cisco.com> wrote:

Hi,

I am adding logging enhancement to my app. There is already a log4j wrapper
is available in my app. But the existing is in jar and I can not modify. The
problem is, now I have two log4j.xml file. one for my enhancement and other
for existing one.

I first initialize existing log4j wrapper, it uses
DOMConfigurator.configure(initUrl) to configure. After this I call my new
APIs, I follow the same DOMConfigurator.configure(initUrl) to override the
configuration.

The problem here is, I have custom appender, which I specified in log4j.xml
of my enhancement, but the custom appender is called twice - once from
existing APIs and another from my APIs.
I dont know how log4j is invoking my custom appeder, when existing APIs are
initialized. I looked this from stack trace.
--
View this message in context: http://old.nabble.com/Log4j-configuration-tp29285028p29285028.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to