Curt Arnold wrote:
On May 26, 2008, at 6:52 AM, Armin Häberling wrote:
Hi all,
I'm facing the following problem. We have a tomcat instance with
multiple webapps. The apps share many libraries in shared/lib
directory, some of them use log4j and some apache commons-logging.
Currently all the apps log to the same log file, which is suboptimal.
We like to have one log file per webapp.
AFAIK one solution for this is to put for each webapp a log4j jar in
the WEB_INF/lib directory and a separate log4j.properties.
As far as I understand the tomcat classloader hierarchy, all libraries
in shared/lib that use log4j must then also be moved to WEB_INF/lib
directory of the webapp. (please correct me if I'm wrong!).
Unfortunately this is not possible in our specific case.
As a second solution I thought of an appender, that writes to
different files, based on the caller thread. It should be possible to
extend this to have different log files per webapp.
Has anyone already done such a thing?
Any hints how this can be easily implemented? I guess I have write a
new Appender extending AppenderSkeleton.
Thanks in advance!
Armin
Both this and the "using separate log files for threads" question would
be good uses for the MultiFileAppender effort that started in the
sandbox a couple of years ago but stalled due to my time constraints and
the lack of any other contributors. It was not left in a usable state,
but the major design ideas should be visible. I have had good
intentions to return to complete it. The code is in
http://svn.apache.org/repos/asf/logging/sandbox/log4j/multifile. Search
the list for multifile for previous discussions.
Basically, the idea is that a FileNamePolicy examines each LoggingEvent
and returns the corresponding file name. The append manages a set of
open files making sure that the number of open files does not exceed a
fixed limit and that files are closed after some extended period of
inactivity.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Hi Curt,
This sounds good. I had a look at the code. Basically what remains to do
is to implement the actual MultiFileAppender class. Once this done it
should be easy to write a custom FileNamePolicies.
I don't know the log4j code well. But with some help, I could create an
initial implementation of the MultiFileAppender.
Have you already done some sort of detail design for the
MultiFileAppender? Is there some code in log4j that I could reuse for
the MultiFileAppender, other than AppenderSkeleton?
Armin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]