Glassfish v2.1 ile netbeans 6.7.1 kullanarak bir web hizmeti projesi yazdım, log4j.properties'i projenin kök dizinine koydum ve şunu kullandım:
static Logger logger = Logger.getLogger(MyClass.class);
Yapıcıda:
PropertyConfigurator.configure("log4j.properties");
ve işlevlerde:
logger.info("...");
logger.error("...");
// ...
ama, bu hata bilgisidir (aslında, fark edebildiğim hemen hemen her dizini koymaya çalıştım):
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.
örnek proje http://www.91files.com/?N3F0QGQPWMDGPBRN0QA8 adresinden alınabilir