Hi- I'm having a problem with log4j. I inherited a project - it's a website that interfaces with a message driven ejb, both run on JRun4 (yikes!). Anyway, all of the log4j statements from the website output on both the console and the log file. However, the EJB log statements do not show up anywhere. It looks like the log4j properties are set as servlet parameters for the log4j init servlet in the web.xml file on the web site. The ant script for this project places the log4j jar in the lib folder for all JRun servers, and it also packages a jar that contains only the log4j properties file for the EJB in this folder. I thought this was suspect and added the properties file to the lib folder within the EJB's jar. I don't have any experience with JRun, and my experience with log4j is elementary at best, but the properties in the file look right to me.
Post the log4j.properties file, lets see if it contains any clues. Also, what is the package in which the EJBs are contained, just to make sure that logging is not disabled for these packages in the log4j.properties. In the EJB code at what level are the messages being logged, are they debug or info or error statements? All this information together might help in identifying the cause.
the path /data/web/site/logs/ does exist on my machine (it's also where the successful logs are written).
All of the logging statements are set with logger.debug("..."). The ejb is in a package com.company.ejb, and all of the functionality is in a jar that is included in the deployment. Those packages are in com.company.common
Yes. I've tried that - with the same result. Should that metter anyway? All of the classes that "do" anything are in the packages com.company and net.company.
Regardless, I have set all debugging to DEBUG, and still no console output or file output.
posted 12 years ago
Hey- I does it matter that the file is not named log4j.properties? Again, I've inherited this project, so at some point it was working. I can;t find any code in the project that initializes the properties. A Search of "PropertyConfigurator" on the whole project returns no results. There must be a PropertyConfigurator to load in the properties, correct?
Without these settings, what is log4j doing? How come I am not getting any exceptions?
does it matter that the file is not named log4j.properties?
It matters. If your log4j configuration file is not named either log4j.xml or log4j.properties, then you will have to manually use the PropertyConfigurator(or DOMConfigurator) to load the specific configuration file.
However if you are using either log4j.properties or log4j.xml file then you need not *explicitly* use the PropertyConfigurator in your code to load the file. When you invoke Logger.getLogger() method available on log4j APIs, it internally does the loading of the appropriate log4j config file
Jaikiran- Thank you so much for your help. I beleive I have fixed it. Once I added code to explicitly read in the properties from the classloader and configure the ejb properties, success! There was no code that would initialize the configuration. This is alarming though. There is a very complax build process since this is a distributed app. I am hoping that this will not affect deployment.
Catch Ernie! Catch the egg! And catch this tiny ad too:
global solutions you can do at home or in your backyard