title: How to write error log or exception into file in java
body: <p>Is there any way to write error log or exception into a file in java. i have gone through Log4j. I googled about it but diidnt find a good solution. I have written a simple code </p>
  
  <pre><code>catch (Exception e) {
      PrintWriter pw = new PrintWriter(new FileOutputStream("Log"));     
      e.printStackTrace(pw);
  } 
  </code></pre>
  
  <p>Is there any other way to log the errors or exception? can any body provide me wwith sample example of Log4j?</p>