Results 1 to 3 of 3
  1. #1
    Katanagas is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Question 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?

  2. #2
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    368
    Rep Power
    5

    Default

    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!

  3. #3
    Katanagas is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    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

  1. Replies: 1
    Last Post: 09-20-2010, 09:32 AM
  2. Replies: 2
    Last Post: 05-06-2010, 06:28 AM
  3. typed events vs untyped events.
    By Drun in forum SWT / JFace
    Replies: 0
    Last Post: 11-23-2009, 01:22 PM
  4. Error logged from JDT Debug UI Window
    By tsc in forum Eclipse
    Replies: 1
    Last Post: 07-10-2008, 09:37 AM
  5. MAC address capturing
    By viswa.tk in forum Java Applets
    Replies: 0
    Last Post: 12-13-2007, 09:36 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •