You can have several "instances" of log4j running within a single VM by
using multiple hierarchies. You better read the code for
org.apache.log4j.Hierarchy to understand this fully.

See org.apache.log4j.SocketServer for an example of how to configure and
utilize multiple Hierarchy instances.

Hope this helps

--

Thomas



| -----Original Message-----
| From: Steven J Saunders [mailto:[EMAIL PROTECTED]]
| Sent: 10 September 2001 07:12
| To: [EMAIL PROTECTED]
| Subject: Log4j in multiple Webapps under single JVM
|
|
| Hi All,
|
| I want to use Log4j to do logging in a J2EE webapp I am writing.
| I'm worried
| about a couple of things though.
|
| The webapp I am writing will be deployed multiple times inside a
| single JVM.
| I want each separate webapp to log to a separate file, and I want
| to be able
| to configure Log4j separately for each webapp.
|
| Can this be done?
|
| At the moment I'm using the following code in a servlet (loaded
| at startup)
| to init Log4j:
|
| String prefix = getServletContext().getRealPath("/");
| String file = getInitParameter("log4j-init-file");
| // if the log4j-init-file is not set, then no point in trying
| if(file != null) {
|    PropertyConfigurator.configure(prefix+file);
|    System.out.println("***** Log4j Initialised *****");
| }
|
| If a second webapp is subsequently launched, will it's
| configuration clobber
| the config of the first? What if I have a config file that looks something
| like this:
|
| log4j.category.<SOME UNIQUE WEBAPP-NAME HERE>=INFO, <WEBAPP-NAME AGAIN>
| log4j.appender.<WEBAPP-NAME AGAIN>=org.apache.log4j.RollingFileAppender
| log4j.appender.<WEBAPP-NAME AGAIN>.File=<WEBAPPNAME AGAIN>.log
|
| Will that work? Can many webapps be loaded one after the other with config
| files like the above without clobbering each other's configs?
|
| Is there a better way to do this?
|
| Thanks.
| __
| Steve Saunders
|
|
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: [EMAIL PROTECTED]
| For additional commands, e-mail: [EMAIL PROTECTED]
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved. 
Confidential. No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to