Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error logging within EJB

 
paul wheaton
Trailboss
Pie
Posts: 21736
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Michael Hildner
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 440
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Matt Midcap
Sheriff
Posts: 440
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Opps. I lied , we are just converting to EJB on this project and this has not been delt with yet.
 
John Davis
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
log4j seems to be getting pretty popular -
http://jakarta.apache.org/log4j/docs/index.html
 
Bob Walker Jr
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic