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 Frank Kurzawa <fr...@kurzawa.com> on 2004/07/14 14:57:52 UTC

Multiple Appenders writing to a single file

Hi,

In my current project I am logging debug output from our own codebase as
well as from a number of other third-party jars running in the same jvm.
I want to log the output from all of these sources to the same file.
I can easily do this by putting multiple <logger>'s in my log4j.xml,
each of which would refer to the same <appender>.
But I also want the log entries from each logger to be distinguished
from one another within the log file. E.g.:
DEBUG [tomcat] beanutils.ConvertUtils          - Convert string
DEBUG [struts] util.PropertyResources         - loadLocale()
DEBUG [mycode] dataAdapter.HSesion         - End finally

where the short name between the square brackets has been added to the
layout by me (log4j).
I can get these distinguishable log entries by associating different 
appenders
with each logger and using the Appender's ConversionPattern param to 
insert
the square-bracketed portion that you see in each log entry. But 
AFAICS, it is
a big mistake to configure multiple appenders to write to the same 
file: there
are major concurrency problems that I seem to be having.

Is there a way to get this functionality, either by using the appenders
in a different manner or by using something other than an appender? Must
I write a custom layout?

Thanks in advance,

Frank


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