cancel
Showing results for 
Search instead for 
Did you mean: 

Logging and Tracing in EJBs

Former Member
0 Kudos

Hi Experts,

I am currently trying to implement Logging in a Stateless EJB.

I have tried the following 2 methods

1. Using log4j.jar

a. Imported log4j.jar as external library

b. Added log4j.properties file in the ejbModule folder

c.Added the following code

private static final long serialVersionUID = 1L;
private static Logger log = Logger.getLogger(EntityFoo.class);

d. Added log.error(), etc. in my code.

e. Created a Web Service on the methods, for testing.

e. Wrapped the EJB project in an Enterprise Application Project and Deployed.

Result:

Logs do not get created, in the location specified in the File attribute of the File appender. Instead i'm getting a message <b>No appenders could be found for logger</b> in the default trace file on the server

2. Using logging.jar available with SAP, i.e the SAP Logging API

a. Imported logging.jar as external library

b.Added the following code

private static Location myLoc = Location.getLocation(EntityFoo.class);

c. Added myLoc.infoT(), etc.

d. In the Enterprise Application Project added the <i>log-configuration.xml</i> file, with suggested parameters.

e. Wrapped the EJB project in that Enterprise Application Project and Deployed.

Result:

Logs do not get created. No Warning or Errors encountered.

In both the cases,

1. Its a Local Projects

2. No compile - time, Run - Time errors

3. Works fine with Java Projects, not with EJBs

Waiting for answers.

Regards,

Alka Panday.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I can only speak for the L4j config.

You have a classloading issue with the log4j.properties file.

You have to initialize it somewhere explicit.

I guess, you deploy your project as a .ear file?

Therefore you have to specify the location if the properties file.

Have a detailed look here:

http://logging.apache.org/log4j/1.2/faq.html#3.5

Rgds

Markus

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Markus,

Thanx for replying.

I did find a work around to solve the problem long back.

Actually the problem was with the WAS. As soon as I restart the Server after deployment, Logging works great.

Regards,

Alka.

Former Member
0 Kudos

Hi Markus,

Logging would work

private static Location myLoc = Location.getLocation(EntityFoo.class);

It would work.

It depends why the log is not getting generated.

There are two main issues.

1> Server not properly configured.

2> Log configuration is not properly set.

Regards

Kaushik Banerjee