title: Java Servlet/ How to write the logs(log.debug and log.error entries) written in the server console to a separate txt file?
body: <p>This is my first java servlet so I would be glad if you can help me and tell me what to do in details :) I can see my program's logs in server console but I need to copy all logs including log.debug and log.error entries to a txt file and later send the txt file via email.</p>
  
  <p>I have to define the directory/file for the logs. I have managed this for a regular java program by adding log4j.xml under src folder so I could set the directory in it, it worked, it is writing logs to a txt file created. But I do not know how to do it for the servlet version of my program. How can I set the directory for logs in the servlet and write logs to a specific txt file?</p>