It's not a secret anymore!
The moose likes Other Open Source Projects and the fly likes Log4J for recording application events? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4J for recording application events?" Watch "Log4J for recording application events?" New topic

Log4J for recording application events?

Bill Compton
Ranch Hand

Joined: Aug 26, 2000
Posts: 186
Our app will log 3 categories of events: debug, error, and "workflow". The first two obviously fit well with Log4J. The "workflow" category is for application events like "finished step N of job Z". These will be relatively infrequent (at least minutes between) and we would never configure them off. We plan to record debug with a RollingFileAppender and would typically configure it as turned off. We want to send error and workflow via JMS (JMSAppender?) to a MDB that will write them to two separate database tables. I assume we would use a custom "workflow" Level to differentiate the appender.

The workflow messages will have some structure -- at least job name, step name, and date/time. Options I see are:
A) Log as text and parse fields in MDB before persisting.
B) Log is an object to retain structure and avoid parsing.
C) Skip Log4J and write custom code for sending via JMS.

Is Log4J a good choice for our "workflow" messages?
Is option B even possible? (Relates to this topic.)

Thanks much!
[ March 13, 2007: Message edited by: Bill Compton ]
M Easter
Ranch Hand

Joined: Feb 11, 2007
Posts: 133
We did something similar to (a) a few years ago. I think we used a TelnetAppender but I think a JMSAppender is better.

Our approach was a proof-of-concept and didn't a full production environment, but it seemed to work pretty well in dev. The enabling idea is that log4j does its logging in a separate thread.

M Easter
Software Composer -
Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Regarding the workflow scenario, be sure to take a look at FAQ Is log4j a reliable logging system?

No. log4j is not reliable. It is a best-effort fail-stop logging system.
I agree. Here's the link:
subject: Log4J for recording application events?
It's not a secret anymore!