Ceki,
I'm trying the way you have mentioned at http://www.qos.ch/logging/sc.html (using LoggerRepository).
In my java class, I have the following code: (I'm using JNDIRS you've mentioned in the above URL)
private static final JNDIRS jndirs = new JNDIRS();
private static final LoggerRepository loggerRepository = jndirs.getLoggerRepository();
private static final Logger logger = loggerRepository.getLogger(MyApp.class.getName());
You don't need to do that if you are using a logger repository. Just use LogManager.setLoggerRepostiory() and define your logger like normal...
private static final Logger logger = Logger.getLogger(MyApp.class.getName());
See info about using repository selectors plus 2 selectors which have already been written (mirrors, but somewhat modifies code in Ceki's article)....
http://nagoya.apache.org/wiki/apachewiki.cgi?Log4JProjectPages/AppContainerLogging
Ceki mentioned JBoss plugins. You could set up a plugin to install the repository selector at JBoss startup and you would be guaranteed to have a separate logging environment. Otherwise, run the IniContextListener servlet context listener in the logj4-sandbox to set things up.
Jake
logger.warn("Just testing a log message with priority set to WARN");
My log4j.properties file is as follows: #### appender writes to a file log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%-5p: %m%n log4j.appender.R.File=errors.log
Still I feel that my log4j.properties file not being read, because I can't see errors.log created anywhere. And there are no errors throws.
Any idea what could be the problem? Can you pl. suggest a solution?
Sriram
-----Original Message----- From: Ceki Gülcü [mailto:[EMAIL PROTECTED] Sent: Thursday, August 28, 2003 12:58 PM To: Log4J Users List Subject: RE: Log file location
We should have a look at the jboss mailing lists. JBoss' class loader is called UnifiedClassLoader. The last time I look at UnifiedClassLoaders about a year ago, it seemed very smart. I'd have to look at the details again.
At 02:05 AM 8/28/2003 -0500, Jacob Kjome wrote:
>Well, if you your app is seeing jboss/lib/log4j.jar in preference to >WEB-INF/lib/log4j.jar, then there is a bug in JBoss. The Servlet spec >states that (contrary to the normal Java2 classloading scheme) classes and >libraries in WEB-INF/classes and WEB-INF/lib are checked first for >classloading and if the classes are not found there, only then does it >look to a higher classloader to attempt to load the classes. > >I know JBoss has some concept of a single classloader across the whole >server (I think that is what I read), but if it doesn't allow for a >separate WebappClassLoader, then I think it is a spec compliance >violation. What does the JBoss group have to say about this? Putting >log4j.jar in WEB-INF/lib *should* provide a completely separate logging >environment from the one JBoss uses. > >Jake > >At 12:09 PM 8/28/2003 +0530, you wrote: >>Hi Jake, >> >>Thanks for the information. I have gone through the stuff you've >>written. >> >>Here's what I'm doing: >>1. I placed log4j-1.2.8.jar in WEB-INF/lib >>2. I placed log4j.properties in WEB-INF/classes >>3. I deployed the application on JBoss 3.2.1 >> >>By default, JBoss has log4j.jar in jboss/lib which is in my classpath. >>So, even my application class loader takes the classes from log4j.jar >>located in jboss/lib? >> >>If I remove log4j.jar in jboss/lib, then I think I will not get server >>log of JBoss. >> >>How to solve this issue? Please inform. >> >>Sriram >> >> >>-----Original Message----- >>From: Jacob Kjome [mailto:[EMAIL PROTECTED] >>Sent: Thursday, August 28, 2003 11:00 AM >>To: Log4J Users List >>Subject: RE: Log file location >> >> >> >>Hi Sriram, >> >>Do you have log4j.jar in WEB-INF/lib? If not, I'd expect default >>initialization not to work. Remember that the webapp class loader can >>see parent class loaders, but the parents cannot see the webapp class >>loader, hence your log4j.properties will definitely not be found. If >>you are trying to use log4j.jar in a parent class loader and want your >>own configuration file to be used in your own logging space, then you >>will need to use a repository selector. See the log4j-sandbox for >>working examples. I wrote something up about this stuff here... >>http://nagoya.apache.org/wiki/apachewiki.cgi?Log4JProjectPages/AppCont >>ainerLogging >> >>Jake >> >>At 09:35 AM 8/28/2003 +0530, you wrote: >> >The properties file is not being read at all!!!! >> > >> >I placed it in WEB-INF/classes. >> > >> >Still it's not being read. >> > >> >I am JBoss and JBoss contains log4j.jar by default and it has >> >log4j.xml in default/conf folder. >> >Probably even my application is taking log4j.xml from that location by >> >default. I need to check that. Anyone who has implemented log4j for their >> >applications on JBoss, pl. suggest. >> > >> > >> >Sriram >> > >> >-----Original Message----- >> >From: Ceki Gülcü [mailto:[EMAIL PROTECTED] >> >Sent: Wednesday, August 27, 2003 6:52 PM >> >To: Log4J Users List >> >Subject: Re: Log file location >> > >> > >> > >> >Is the properties file being read at all? >> > >> >At 06:25 PM 8/27/2003 +0530, sriram wrote: >> > >Hi, >> > > >> > >I am unable to set log file location. I searched the forum for old >> > >messages and found some. I tried the way it was mentioned in those >> > >messages, but still my problem is not solved. >> > > >> > >My log4j.properties file is as follows: >> > > >> > >log4j.rootCategory=WARN, dest1, R >> > >log4j.appender.dest1=org.apache.log4j.ConsoleAppender >> > >log4j.appender.dest1.layout=org.apache.log4j.PatternLayout >> > >log4j.appender.dest1.layout.ConversionPattern=%-5p: %m%n >> > > >> > >#### appender writes to a file >> > >log4j.appender.R=org.apache.log4j.RollingFileAppender >> > >log4j.appender.R.layout=org.apache.log4j.PatternLayout >> > >log4j.appender.R.layout.ConversionPattern=%-5p: %m%n >> > >log4j.appender.R.File=d:/jboss/errors.log >> > > >> > > >> > >I packaged by application as .ear and deployed it on JBoss >> > >running on Win 2000. >> > > >> > >When I run the application, I can see the log messages on JBoss >> > >console, but these messages are not getting stored in the file >> > >I've specified (d:/jboss/errors.log). >> > > >> > >What could be the problem? In fact, initially I tried >> > >${jboss.home}/errors.log, but it didn't work. So I thought of hard >> > >coding the file location and tried it out. Still the same problem. >> > > >> > >Can someone please suggest a solution? >> > > >> > >Thanks >> > >Sriram >> > > >> > >> >-- >> >Ceki For log4j documentation consider "The complete log4j manual" >> > ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp >> > >> > >> > >> > >> >-------------------------------------------------------------------- >> >- >> >To unsubscribe, e-mail: [EMAIL PROTECTED] >> >For additional commands, e-mail: [EMAIL PROTECTED] >> >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >
-- Ceki For log4j documentation consider "The complete log4j manual" ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]