title: Tomcat servlet logging
body: <p>I'm new to Servlet containers and have created a web application using Tomcat 6.0.26.  I have 'TODO: log' scattered throughout my code.  I see there exists:</p>
  
  <p>myServlet.getServletContext().log()</p>
  
  <p>which appears to write to a file prefixed with 'localhost' in the Tomcat '/logs' directory.  I don't need any advanced logging capability, but I'd like a date, time, message and stack trace at minimum.  In addition, I've created some classes used by my various servlets that need logging capabilities as well. Do I need to inject a SevletContext into these classes so they can log?</p>
  
  <p>It appears that log4j from Apache is a popular logging package, but I'm not sure if it worth the trouble of setting it up.</p>
  
  <p>What would be the recommended way of logging for my needs?</p>