geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ying Tang <yingtang1...@gmail.com>
Subject Re: log4jResource setting in GBean: ApplicationLog4jConfigurationGBean
Date Tue, 14 Jul 2009 02:31:18 GMT
Thanks David and Viola.

 The document
http://cwiki.apache.org/GMOxDOC22/configuring-application-specific-logging-with-log4j.htmlhas
been updated with this issue:


You can also use a log4j.properties file in your classpath, for example, in
WEB-INF/classes/META-INF. (If you prefer not to place this file under
WEB-INF/classes/, the path of this file must be added to your
classpath).But this will obstruct anyone trying to configure logging
as the file will
remain packed in your application somewhere hard to find.

<gbean name="DirectoryLog4jConfiguration" class=
"org.apache.geronimo.system.logging.log4j.ApplicationLog4jConfigurationGBean">

<attribute name="log4jResource">META-INF/log4j.properties</attribute>
 </gbean>



Best Regards,

Ying Tang

2009/6/9 David Jencks <david_jencks@yahoo.com>

>
> On Jun 8, 2009, at 11:03 PM, viola.lu wrote:
>
>
>> 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?
>>
>
> Because that's not in your classpath.
>
> Try WEB-INF/classes/META-INF/log4j.properties.
>
> thanks
> david jencks
>
>
>
>>
>> Anyone can figure it out? Thanks.
>> --
>> View this message in context:
>> http://www.nabble.com/log4jResource-setting-in-GBean%3A-ApplicationLog4jConfigurationGBean-tp23936783s134p23936783.html
>> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>>
>>

Mime
View raw message