Results 1 to 3 of 3
Thread: log4j - capturing logged events
- 10-24-2010, 03:41 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 3
- Rep Power
- 0
log4j - capturing logged events
Hi,
I've seen other log4j questions in this forum so I hope it's ok for me to bring this topic here.
We have a number of classes trapping exceptions and logging them via log4j. This process is working very well. Now, we need to display a JTable with some of these exceptions: pretty displayed and segregated by exception fields as columns for non-technical users. We have a root (custom) exception class that all thrown exceptions inherit from. It has a number of internal data members. For example: tradeID, location, etc... For each log4j event our JTable needs to show a line with these data members as cols.
I'd think that registering an log4j appender or some other form of listener is the right approach. Any advise how to proceed?
- 10-25-2010, 11:38 AM #2
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
For non-technical user, usually HTML log file is created, they can open it from remote location using just browser.
You use concept of Layout for this like HTMLLayout. There are many examples around how you can to this.
So there are 2 things to worry about: what will you log and who will read that.
Don't expect from non-technician users to know anything about exceptions - just log some plastic description for them and don't log too many or to RED color that will scare a * out of them. "SimpleLayout and PatternLayout classes ignore Java Throwable errors and exceptions. HTMLLayout and XMLLayout handle them".
For coders and debuggers use low level of log, and some PatternLayout for proper info like: time, class, method ...where Exc happened.
First experiment then ask coders and non-techical personal are they satisfied with format of log. Take care of size and big audit.
After some time you will create your log file helpers that you can include on many future projects - to spend some time it will surely pay off.
good luck!
- 10-25-2010, 02:07 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 3
- Rep Power
- 0
I probably didn't explain my question correctly or perhaps I don't understand the answer. I don't want an HTML page. We have a stand-alone swing app. I need a JTable in it populated with the data members of an exception logged via a logger. In our code, we do this in many places:
.... catch ( InstrumentException cex ) {
// where log is a ...log4j.Logger
log.warn("Unable to process instrument " + cex.getInstID(), cex); }
Where InstrumentException is a custom exception derived from java.lang.Exception. It has many more attributes that should be displayed in a JTable so the user can filter by them, sort them, etc...
I can always modify all catch statements and add the exceptions to a collection, but that seems too intrusive. There are a lot of classes. We already use log.warn(..., cex) and log.error(..., cex). We should be able to register as listeners for such events and if the exception being thrown is instanceof InstrumentException, then add it to our JTable.
Any idea?
Similar Threads
-
Problem on Log4j: How to include custom <filter/> into JBoss (log4j.xml)?
By holyjohn in forum Advanced JavaReplies: 1Last Post: 09-20-2010, 08:32 AM -
User is no longer logged in when switching between two websites
By kchandu in forum Java ServletReplies: 2Last Post: 05-06-2010, 05:28 AM -
typed events vs untyped events.
By Drun in forum SWT / JFaceReplies: 0Last Post: 11-23-2009, 12:22 PM -
Error logged from JDT Debug UI Window
By tsc in forum EclipseReplies: 1Last Post: 07-10-2008, 08:37 AM -
MAC address capturing
By viswa.tk in forum Java AppletsReplies: 0Last Post: 12-13-2007, 08:36 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks