我应该把log4j.properties文件放在哪里?
我使用netbeans 6.7.1和glassfish v2.1编写了一个Web服务项目,将log4j.properties放在项目的根目录下并使用:
static Logger logger = Logger.getLogger(MyClass.class);
在构造函数中:
PropertyConfigurator.configure("log4j.properties");
和函数中:
logger.info("...");
logger.error("...");
// ...
但是,这是错误信息(实际上,我试图把它放在我能意识到的几乎每个dir上):
log4j:ERROR Could not read configuration file [log4j.properties].
java.io.FileNotFoundException: log4j.properties (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:297)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:315)
at com.corp.ors.demo.OrsDemo.main(OrisDemo.java:228)
log4j:ERROR Ignoring configuration file [log4j.properties].
log4j:WARN No appenders could be found for logger (com.corp.ors.demo.OrsDemo).
log4j:WARN Please initialize the log4j system properly.