*
The moose likes EJB and other Java EE Technologies and the fly likes Log4j not working in EJB project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Log4j not working in EJB project" Watch "Log4j not working in EJB project" New topic
Author

Log4j not working in EJB project

Hitesh Guna
Greenhorn

Joined: Apr 23, 2013
Posts: 4
Hi,

I have an EAR project.
I have two separate schedulers running in it and i want to direct the logs of the schedulers in 2 different log files.
i have placed the log4j.properties file in the resources folder.

But the logs are not being directed to the log files.

Following is my log4j.properties file.



Any idea???
Hitesh Guna
Greenhorn

Joined: Apr 23, 2013
Posts: 4
Any Help???
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

Hi Hitesh,
Welcome to the Ranch!

Firs of all, is any logging file created at all? Your log4j configuration looks complex to me. I think you should start with a simple one and then build on it.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Hitesh Guna
Greenhorn

Joined: Apr 23, 2013
Posts: 4
Hi Ranganathan,

Thanks for your reply...

I am getting a feeling that the configuration file is not being read...

because i have used the same configuration file in other project...and it created proper log files...

Right now...the project is using EJB3.0 & is being deployed on JBOSS 5.1...

I have tried the same code using EJB3.1 & JBOSS 6...Here i added extra class with @Startup annotation at the class level & @PostConstruct at the method level. Inside this method i had loaded the configuration...

Now the problem is, there is nothing like @Startup in EJB3 ,& EJB3.1 is not supported by JBOSS 5.1...So i cant add such startup code...

And by default right now the logs are being redirected to server.log...But i want the log for the two schedulers to go in different log files...can you suggest anything???
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

Ok. You can try having a ServletContextListener and do this config setup there. If config setup has to be done only in EJB, then you can invoke that EJB call inside this servlet context listener call. But, you will have to add a war to the ear in this case. This may not be the best solution though...
Hitesh Guna
Greenhorn

Joined: Apr 23, 2013
Posts: 4
Ok...That can be a nice workaround...
But still...any other ideas???
N Thanks for your prompt reply...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Log4j not working in EJB project