Hello there,
 
I am using an init servlet to load my log4j.properties file during app start 
up...
public class Log4jInitServlet extends HttpServlet {
     public void init() throws ServletException {
                Properties props = new Properties();
                try {
            props.load(this.getClass().getClassLoader().getResourceAsStream(
                                        "/log4j.properties"));
                } catch (IOException e) {
                   e.printStackTrace();
                }
        }
}
 The log4j.properties file:
log4j.rootLogger=WARN, stdout
log4j.logger.acme.myapp=DEBUG
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
 Question(s):
 
(1)
Let's say I want to use a file appender for logging different parts of
the app's behavior, do I need to create a different properties file? 
 
(2) If not, how would I integrate that with the properties file above?

(3) Is there a way I set the DEBUG warning to just log to the Console and the 
LOG warning to just log to specific files (which I specify)?
 
(4) What if I wanted two separate log files generated for the file appender?
 
(e.g. one being for cars.log and another one being planes.log)
 
(5) Do I have to create a different init servlet and different properties file?
 
Happy programming,

Reply via email to