Hello James, The functionality you are looking for is to be able to log within unique logger repositories using a custom logger repository selector. I have implemented such a selector (and a servlet context listener which configures log4j to use it at app/server startup) which keys logger repositories on the current classloader. Ceki has written about a repository selector which would use JNDI to key logger repositories.
Now, since you are using JBoss and they have their single classloader concept (which, admittedly, I'm not so familiar with) I'm not sure the repository selector that I wrote will work for you. It certainly works in an environment where each webapp has its own unique classloader. This still might be true for JBoss, but I'm not positive. To check out the repository selector I wrote, look here: http://cvs.apache.org/viewcvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/selector/ContextClassLoaderSelector.java?rev=1.3&content-type=text/vnd.viewcvs-markup See the servlet context listener which initializes Log4j to use this custom selector here: http://cvs.apache.org/viewcvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/InitContextListener.java?rev=1.2&content-type=text/vnd.viewcvs-markup Note that Log4j will only use *ONE* custom repository selector. Once one is installed, the only way to change it to re-install the selector along with the original guard object which is used to protect the selector from being changed by a process not meant to do so. So, unless you store the guard, you can pretty much assume that this is a one-shot thing. As such, ideally, the container should be responsible for installing the selector. My servlet context listener allows for any particular webapp to install the selector if one isn't already installed. If one is, the installation will fail and the exception hidden. In this situation, it is assumed that whatever process did the install knew what it was doing and the app will just have to live with the decision. For sure, read Ceki's article about custom selectors and pay attention to the JNDI selector discussion: http://qos.ch/logging/sc.html Note, if you implement a JNDI selector that works for you, it would be great if you could contribute that back to the Log4j-sandbox project! Jake Tuesday, February 25, 2003, 1:48:51 PM, you wrote: CJ> An answer to this question/problem is very important to my project group so CJ> please take time to read and understand it. Thanks. I struggled with CJ> posting this to a JBOSS group but decided it was more of an issue with the CJ> use of Log4J and not so much how JBOSS was using it. CJ> I am using JBOSS and am attempting to define application independent logging CJ> using Log4J. CJ> JBOSS uses Log4J for their logging as well, which is where my problems CJ> begin. CJ> If I use the PropertyConfigurator to configure log4J using an application CJ> specific config file. Its settings conflict with the JBOSS logging. My CJ> first attempt was defining the root and file appenders for the root logger CJ> which is probably what was throwing the Log4J logging into a loop. CJ> My solution was to define a category and log to that vs. getting the logger CJ> and logging to it. CJ> The results were encouraging but problematic as well. My error, debug, info CJ> messages are showing up in the JBOSS console log just fine, but are appended CJ> to an [INFO] message from the JBOSS (log4j) logging. So it appears that CJ> every message logged to my category is getting appended to a JBOSS log CJ> message (in this case INFO priority) before being logged to the console or CJ> file. CJ> How can I define my application specific logging so it can coexist with the CJ> logging configuration defined by the app server which uses log4J but be CJ> independent. I do not want to have to modify the log4J configuration that CJ> is setup by the JBOSS server implementation. I want to be able to configure CJ> my own configuration file, load it with a console and file appenders that CJ> coexist with the ones in the JBOSS specific log4J configuration but do not CJ> conflict with the root ones defined. HOW????? CJ> Below is a snapshot of my application log4j configuration file that I am CJ> loading. The JBOSS log4j configuration appears to define a console and file CJ> appender for the root logger. This configuration works with the caveat that CJ> any logging to this category gets appended to the JBOSS log text before CJ> being displayed to the console or log file. CJ> ## The server.log file appender for LightSpeed CJ> log4j.category.LightSpeed=, LightSpeed_Console, LightSpeed_Default CJ> log4j.appender.LightSpeed_Default=org.apache.log4j.RollingFileAppender CJ> log4j.appender.LightSpeed_Default.File=server.log CJ> log4j.appender.LightSpeed_Default.MaxFileSize=500KB CJ> log4j.appender.LightSpeed_Default.MaxBackupIndex=1 CJ> log4j.appender.LightSpeed_Default.layout=org.apache.log4j.PatternLayout CJ> #log4j.appender.LightSpeed_Default.layout.ConversionPattern=%d %-5p [%t] CJ> %-17c{2} (%13F:%L) %3x - %m\n CJ> #log4j.appender.LightSpeed_Default.layout.ConversionPattern=[%d{ABSOLUTE},%c CJ> {1}] %m%n CJ> log4j.appender.LightSpeed_Default.layout.ConversionPattern=%d{ABSOLUTE},%-17 CJ> c [%-5p] - %m%n CJ> #log4j.additivity.LightSpeed=false CJ> log4j.appender.LightSpeed_Console=org.apache.log4j.ConsoleAppender CJ> log4j.appender.LightSpeed_Console.layout=org.apache.log4j.PatternLayout CJ> log4j.appender.LightSpeed_Console.layout.ConversionPattern=%d{ABSOLUTE},%-17 CJ> c [%-5p] - %m%n CJ> Thanks, CJ> J.D. CJ> This electronic message transmission contains information from the Company that may be proprietary, confidential and/or privileged. CJ> The information is intended only for the use of the individual(s) or entity named above. If you are not the intended recipient, be CJ> aware that any disclosure, copying or distribution or use of the contents of this information is prohibited. If you have received CJ> this electronic transmission in error, please notify the sender immediately by replying to the address listed in the "From:" field. -- Best regards, Jacob mailto:[EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]