hi, i follow steps in
http://cwiki.apache.org/GMOxDOC22/configuring-application-specific-logging-with-log4j.html, and add gbean information in geronimo-web.xml using log4jResource.
<dep:gbean class="org.apache.geronimo.system.logging.log4j.ApplicationLog4jConfigurationGBean" name="testlogLog4jConfiguration">
<dep:attribute name="log4jResource">META-INF/log4j.properties</dep:attribute>
</dep:gbean>
But "Can't find META-INF/log4j.properties " error always exists. if i use log4jFile setting like below:
<dep:gbean class="org.apache.geronimo.system.logging.log4j.ApplicationLog4jConfigurationGBean" name="testlogLog4jConfiguration">
<dep:attribute name="log4jFile">var/log/log4j.properties</dep:attribute>
<dep:reference name="ServerInfo"><dep:name>ServerInfo</dep:name></dep:reference>
<!--<dep:attribute name="log4jResource">META-INF/log4j.properties</dep:attribute>-->
</dep:gbean>
it works well.
I looked into ApplicationLog4jConfigurationGBean code:
...
InputStream in;
if (log4jFile != null) {
File file = serverInfo.resolveServer(log4jFile);
in = new FileInputStream(file);
} else if (log4jResource != null) {
in = classloader.getResourceAsStream(log4jResource);
if (in == null) {
throw new NullPointerException("No log4j properties resource found at " + log4jResource);
}
} else {
return;
}
...
in = classloader.getResourceAsStream(log4jResource);
ClassLoader will search this file from classpath, and my project structure is:
LogWeb
---src(testlog.java
---WebContent
META-INF(log4j.properties)
WEB-INF
index.jsp
----
Why it can't find out file META-INF/log4j.properties?
Anyone can figure it out? Thanks.