users@glassfish.java.net

How to avoid writing logs to server.log

From: Bhaarat Sharma <bhaarat.s_at_gmail.com>
Date: Mon, 23 Aug 2010 18:52:58 -0400

I have an application that uses log4j and is deployed on GlassFish V3.
There are multiple war files deployed under same instance. So I want to log
all my errors to my_system.log rather than putting them in server.log.

To do this I am catching the exception and then throwing it again because I
still want the execution to halt:

public void fetchSomething (String userId) {
    try {
       //go to the database
       //fetch records
    }
   catch (SQLException ex) {
      log.error(ex, ex) //this logs to my_system.log
      throw new RuntimeException () //this to halt the execution
    }
}

Problem I am having is that since I am throwing the exception, it is being
written to server.log. Is there a way I can avoid this?? I have to throw
the exception because I want execution thread to stop if an error occurred.


Is there a setting in application server and/or log4j using which I can
avoid writing certain exceptions to server.log (RuntimeException in this
case)

Thanks