*
The moose likes EJB and other Java EE Technologies and the fly likes error logging within EJB 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 "error logging within EJB" Watch "error logging within EJB" New topic
Author

error logging within EJB

paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20493
    ∞

File I/O violates "bean law"... and yet if you encounter an error within an EJB, you
might want to log it.... It seems that involving RMI would be wise. Or JMS? Could
something be worked into a war file along these lines to simplify set up on test systems
and multiple production systems?

permaculture Wood Burning Stoves 2.0 - 4-DVD set
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Lots of options:
1) Most EJB servers have built in logging capability.
2) Log to a database
3) Log to a text file using JDBC
4) Log to a separate logging system using JMS
[This message has been edited by Thomas Paul (edited February 21, 2001).]


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Michael Hildner
Ranch Hand

Joined: Oct 13, 2000
Posts: 297
I've been using JMS to track errors/status of my beans (we use WebLogic 6.0). I've got a class in the server's classpath so it's available to beans, servlets, etc. It pretty much consists of one static method, so when we want to track something, we just call it, passing the exception and a severity String. This class posts to a JMS topic using an ObjectMessage.
I have a client program that I run that subscribes to this particular topic, so I can see what's going on with our whole app. Pretty cool, as the production system is 1,000 miles away.
Matt Midcap
Sheriff

Joined: Jan 07, 1999
Posts: 440
I believe we are using item #3 on Thomas's list - have to check and make sure.
[This message has been edited by Matt Midcap (edited February 21, 2001).]


Best Regards,<br />Matt Midcap
Matt Midcap
Sheriff

Joined: Jan 07, 1999
Posts: 440
Opps. I lied , we are just converting to EJB on this project and this has not been delt with yet.
John Davis
Ranch Hand

Joined: Nov 02, 2000
Posts: 189
Since servlets are most often used as "the EJB client" the servlet execution engine could be used for the specified logging requirements in these cases. Simply design the EJB to refer the encountered error to the client servlet who can then utilize the servlet api to log (via servletContext().log() ) the error.
------------------
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
In our case, the servlet engine and the EJB server are one and the same, BEA WebLogic, so we just use the built-in logging capability.
Jim Baiter
Ranch Hand

Joined: Jan 05, 2001
Posts: 532
log4j seems to be getting pretty popular -
http://jakarta.apache.org/log4j/docs/index.html
Bob Walker Jr
Ranch Hand

Joined: Jun 02, 2003
Posts: 46
Just got this thread while searching the web. It is kind of surprising that EJBContext does not have any method for logging the way ServletContext has. So what is the standard way of loggin debug messages? What do people most often use? I use System.out.println. It requires no configuration and the messages go the the server log file. Of course, I know it is a "frowned upon" way to log debug messages, but is there any other faster, easier, and portable way?
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
Why don't you just throw the exception. Let the calling system handle it!
If you really need EJB metrics, use a third party system, such as introscope (wilytechnologies.com) for this.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Originally posted by Dana Hanna:
Why don't you just throw the exception. Let the calling system handle it!
If you really need EJB metrics, use a third party system, such as introscope (wilytechnologies.com) for this.

Not all log entries should result in exceptions. Personally, I use Log4J for all of my logging purposes. Lately, I have been using Jakarta Commons Logging on top of Log4J. However, I don't see much of a benefit since I really don't think I will ever have to switch out logging implementations.
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
Originally posted by Chris Mathews:
Not all log entries should result in exceptions. Personally, I use Log4J for all of my logging purposes.

Oops, you're right. Sorry, I think my mind was in another thread! However, I believe the question is how to do this without file IO. I would use Log4J with the JMS, JDBC, or a custom appender.
Bob Walker Jr
Ranch Hand

Joined: Jun 02, 2003
Posts: 46
Originally posted by Dana Hanna:

Oops, you're right. Sorry, I think my mind was in another thread! However, I believe the question is how to do this without file IO. I would use Log4J with the JMS, JDBC, or a custom appender.

Doesn't the fact that you are forced to use a third party library for such a basic thing mean that EJB designers forgot something? I am sure that they are very smart people but how can they not have log() methods in the EJBContext when they have log methods in the ServletContext? There must be a reason behind it.
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
I agree that something should be offered. It's not like they don't make mistakes though... Thread.run should have protected access, and the whole Date class situation was out of control years ago.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: error logging within EJB
 
Similar Threads
deploying sample banking example
Entity Bean depolyment Error in WL8.1 beta
when the home object will be created??
JBuilder 6 and WLS 5.1
how can i locate the properties files within the ejb container?