You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Mike Brodhead <mk...@black-ice.org> on 2001/12/19 01:20:38 UTC

Thread safety

I am currently seeing garbled log entries in Log4j when two threads
are logging simultaneously.

Thread A is logging to Category Foo, which should write to foo.txt.
Thread B is logging to Category Bar, which should write to bar.txt.
Most of the time, when I restart my app, I see the same log messages
going to BOTH foo.txt and bar.txt.  Moreover, the messages are coming
in on top of one another, so the individual entries are being garbled.

To make matters more interesting, every so often (perhaps one restart
in ten) things behave properly, with all entries going to the correct
place.

My guess is that I am doing something stupid, but I am at a loss to
see my mistake.

Some (possibly) pertinent facts:
  * My app has an existing configuration system, so I am configuring
    Log4j manually via the API.
  * I am subclassing Category, CategoryFactory, and PatternLayout
  * My layout produces multiple lines.  (However, the entries are
    often garbled within the individual lines.)

Any thoughts on how to chase this down?  Have I found a bug in Log4j?
Have I violated some assumption of the API?  

Thanks in advance,

--mkb


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>