aspose file tools*
The moose likes Other Open Source Projects and the fly likes Log4j - no output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4j - no output" Watch "Log4j - no output" New topic
Author

Log4j - no output

Dudley Dawson
Ranch Hand

Joined: Dec 14, 2004
Posts: 57
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.

Any help would be greatly appreciated!
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

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.


[My Blog] [JavaRanch Journal]
Dudley Dawson
Ranch Hand

Joined: Dec 14, 2004
Posts: 57
sure. here it is:



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
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

log4j.logger.net.company=DEBUG, defaultFileAppender, stdout


Shouldn't this be:

Dudley Dawson
Ranch Hand

Joined: Dec 14, 2004
Posts: 57
No, actually - there are 2 packages.
net.company and com.company
confusing, but they are both in there.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

log4j.rootLogger=INFO,defaultFileAppender,stdout


The root logger is set to INFO level. You mentioned that the ejbs are logging at debug level using logger.debug. Change it to :



Let us know if you still see the issue.
Dudley Dawson
Ranch Hand

Joined: Dec 14, 2004
Posts: 57
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.
Dudley Dawson
Ranch Hand

Joined: Dec 14, 2004
Posts: 57
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?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

Should that metter anyway?


Yes. It does matter. If the logger is set to INFO level and you are logging at debug level through your code then, the log messages will not written.

Regardless, I have set all debugging to DEBUG, and still no console output or file output.


Your log4j.properties looks fine. In your EJB how is the logger instantiated. Can you post that code? Usually it is something like:



Post the code from the EJB where the logger is instantiated
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

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
Dudley Dawson
Ranch Hand

Joined: Dec 14, 2004
Posts: 57
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.

Thanks again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Log4j - no output