Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB Logging

 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is logging achieved under EJBs? I suspect that the java.util.logging.* classes aren't going to work well in that environment. Or can I create some type of Handler tied to an entity bean or other type of database access?
I know it can be done using JMS, and I may go that route if no other option is available, but I'm looking for alternatives.
Sure this wheel has already been invented. It's wonder that they didn't consider Logging in J2EE when they added it in 1.4--unless it is a really difficult problem and no one is quite sure yet of the bets way to handle it.

--Mark
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I use Log4J and it works just fine and dandy. I think you may be yet another one of those folks who are convinced by the back part of the EJB spec that somehow you can't write to a file starting from an EJB and still be "ideologically pure"...
Kyle
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that was part of it.
The other part is synchronization. I don't know much about how it's implamented. I do know a little about Java's Loggin in 1.4 which I believed is based on Log4j. What happens when I try to write to the log from different EJBs? Will I impact the server's performance, as the EJBs contend to write to the logger? Will the logger have sufficent buffering?
Anything else I should know?

--Mark
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Log4J AND the JDK 1.4 logger are already optimized for multithreaded programming. In short, don't worry about it.
Kyle
 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
log4j's beauty lies one property. messages can be written to console/files/can be avoided by just chaging an attribute in its properties file.
At coding time its set to throw messages to console ,at production to files.
observation, it is !
Manas
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading this with much interest as I am having a devil of a time getting log4j to work in WAS 4--
I want to log both web and ejb tiers using one logger and one property file. I also want to be able to access this property file dynamically for update (via a servlet/jsp).
Can someone please set me straight re: where to
put the log4j.jar? I currently have it in the j2ee application and reference that jar in the ejbs and web layer. I have the property file in a directory added to the classpath. I see that the logger is being initialized but nothing is being written to the log (in WSAD). In WAS I am seeing what I believe are class loader errors via 'no appenders found for ' EJB components.
Should I set up log4j as its own project and include it in the enterprise application?
thanks!
Max
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic