• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Log4j - no output

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



Shouldn't this be:

 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, actually - there are 2 packages.
net.company and com.company
confusing, but they are both in there.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic