I am new to log4j! I am using IntelliJ Idea. I am deployng EAR app on Jboss 7.1.1 Final. My EAR app contains EJB and WAR packages.
So the question is - Where to put log4j.properties or log4j.xml? And do I need to initialize it in code or not?
I am new to log4j! I am using IntelliJ Idea. I am deployng EAR app on Jboss 7.1.1 Final. My EAR app contains EJB and WAR packages.
So the question is - Where to put log4j.properties or log4j.xml? And do I need to initialize it in code or not?
You can specify log4j.xml
which you want to use during jvm startup by using parameter -Dlog4j.configuration=\path\to\file
you need to put it in any 'classpath' location. And use it like in the example
package com.foo;
import org.apache.log4j.Logger;
public class Bar {
static Logger logger = Logger.getLogger(Bar.class);
public void doIt() {
logger.debug("Did it again!");
}
}
There is no need to include a log4j.xml or logging.properties configuration file with your application if you're using JBoss AS 7. The only reason to do that would be to use an appender that is not included in the JBoss AS 7 logging subsystem.
I found that a java project in intellij (not spring) must have the log4j.xml (or properties) at myproject/src/main/resources/log4j.xml
I just created the resources directory there. No other location appears to work.
I believe the reason is that the properties then get included in the build and the .jar