title: Using log4j with Web container (part of the J2EE server)
body: <p>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:</p>
  
  <pre><code>public class SomeClass {
      OurLogger log = OurLogger.getLogger ("myapp", SomeClass.class);
      public void someMethod {
          try {
          //code
          }
          catch (DataAccessException e)
          {
              log.error(e.getMessage(), e);
          }
      }
  }
  </code></pre>
  
  <p>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 <code>server.log</code>.</p>
  
  <p>However, for some cases where we are not catching the error...the stack trace is being written on <code>server.log</code> In these cases also we would like to send stack errors to <code>myapp.log</code>.  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 <code>server.log</code> but instead to <code>myapp.log</code>?  Other than catching the exception by code change of course.  </p>