When our application throws errors that we catch, we put the message and stacktrace in a log file created specifically for our application (myapp.log). For example:
public class SomeClass {
OurLogger log = OurLogger.getLogger ("myapp", SomeClass.class);
public void someMethod {
try {
//code
}
catch (DataAccessException e)
{
log.error(e.getMessage(), e);
}
}
}
We do this because since we are in a environment where multiple apps reside on an application server...ours and every other applications logs should be seperate from the server.log
.
However, for some cases where we are not catching the error...the stack trace is being written on server.log
In these cases also we would like to send stack errors to myapp.log
. I know we can define an exception in web.xml and forward to a jsp page but is there a way, in this case, to not send the stack trace to server.log
but instead to myapp.log
? Other than catching the exception by code change of course.