我使用 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("...");
// ...
但是,它是错误信息(实际上,我已经尝试把它几乎每一个目录,我可以实现) :
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.