From user-return-13641-apmail-geronimo-user-archive=geronimo.apache.org@geronimo.apache.org Tue Jul 14 02:31:43 2009 Return-Path: Delivered-To: apmail-geronimo-user-archive@www.apache.org Received: (qmail 52298 invoked from network); 14 Jul 2009 02:31:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Jul 2009 02:31:43 -0000 Received: (qmail 93018 invoked by uid 500); 14 Jul 2009 02:31:52 -0000 Delivered-To: apmail-geronimo-user-archive@geronimo.apache.org Received: (qmail 92937 invoked by uid 500); 14 Jul 2009 02:31:51 -0000 Mailing-List: contact user-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: user@geronimo.apache.org List-Id: Delivered-To: mailing list user@geronimo.apache.org Received: (qmail 92929 invoked by uid 99); 14 Jul 2009 02:31:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Jul 2009 02:31:51 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of yingtang1983@gmail.com designates 209.85.222.182 as permitted sender) Received: from [209.85.222.182] (HELO mail-pz0-f182.google.com) (209.85.222.182) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Jul 2009 02:31:40 +0000 Received: by pzk12 with SMTP id 12so2097234pzk.27 for ; Mon, 13 Jul 2009 19:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=KoQZYLdWJf9JHhc2cr4fRx7j2uXoxUDmNUxi/TzFnrQ=; b=ALp/NqYIAxc1ey+HdjBozoPbUiPKAU2lmTEjCPDIl/W3r1U76ZM4Z5/i43F+7Ei7b9 33IPcqI1V9+70/SPkjpXGAIBFA0bEGdPoZws9m0m0Z+1HiEEjlCYPY5zW8MrBwcs4dTu FrkD65qDQjHaUCvvxLtdJmdUM8wi6np2jg0EI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=SZQ7kaVwQJvwOycya4yBmZAVoj6yMLmKzwOca82N9gOd+G3I7Zx4m566Rt91sedST6 s7LfPPeBdP56lDfCeBQGkwq7jdGKy5FMf4LrufjwoWkXcMhozFT7sttbjHV18WMKJQ/c q9xaZ6t4T8PbU6iTmhBm0A9T7ENJyvVrZ1k4Y= MIME-Version: 1.0 Received: by 10.142.126.6 with SMTP id y6mr1767139wfc.122.1247538678694; Mon, 13 Jul 2009 19:31:18 -0700 (PDT) In-Reply-To: <8409378B-514E-4343-BE2B-C978EB82DD03@yahoo.com> References: <23936783.post@talk.nabble.com> <8409378B-514E-4343-BE2B-C978EB82DD03@yahoo.com> Date: Tue, 14 Jul 2009 10:31:18 +0800 Message-ID: <25b884430907131931i574700f8te0cb29a32abe9969@mail.gmail.com> Subject: Re: log4jResource setting in GBean: ApplicationLog4jConfigurationGBean From: Ying Tang To: user@geronimo.apache.org Content-Type: multipart/alternative; boundary=000e0cd3108ac9830a046ea13b3f X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd3108ac9830a046ea13b3f Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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. META-INF/log4j.properties Best Regards, Ying Tang 2009/6/9 David Jencks > > 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. >> >> > >> class="org.apache.geronimo.system.logging.log4j.ApplicationLog4jConfigurationGBean" >> name="testlogLog4jConfiguration"> >> >> > name="log4jResource">META-INF/log4j.properties >> >> >> >> But "Can't find META-INF/log4j.properties " error always exists. if i use >> log4jFile setting like below: >> >> > >> class="org.apache.geronimo.system.logging.log4j.ApplicationLog4jConfigurationGBean" >> name="testlogLog4jConfiguration"> >> > name="log4jFile">var/log/log4j.properties >> > name="ServerInfo">ServerInfo >> >> >> >> 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. >> >> --000e0cd3108ac9830a046ea13b3f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks David and Viola.

=A0The document http://cwiki.apache.org/GMOxDOC22/configuring-application= -specific-logging-with-log4j.html has been updated with this issue:


You can also use a log4j.properties file i= n 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 b= e 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=A0name=3D"DirectoryLog4jConfi= guration"=A0class=3D"org.apache.geronimo.system.loggi= ng.log4j.ApplicationLog4jConfigurationGBean">
<attribute=A0name=3D"log4jResource">META-INF/log4j.proper= ties</attribute>
=A0</gbean>



Be= st Regards,

Ying Tang

2009/6/9 David Jencks <david_jencks@yah= oo.com>

On Jun 8, 2009, at 11:03 PM, = viola.lu wrote:


hi, i follow steps in
http://cwiki.apache.org/GMOxD= OC22/configuring-application-specific-logging-with-log4j.html,
and add gbean information in geronimo-web.xml using log4jResource.

<dep:gbean
class=3D"org.apache.geronimo.system.logging.log4j.ApplicationLog4jConf= igurationGBean"
name=3D"testlogLog4jConfiguration">

=A0 <dep:attribute
name=3D"log4jResource">META-INF/log4j.properties</dep:attri= bute>

=A0 </dep:gbean>

But "Can't find META-INF/log4j.properties " error always exis= ts. if i use
log4jFile setting like below:

<dep:gbean
class=3D"org.apache.geronimo.system.logging.log4j.ApplicationLog4jConf= igurationGBean"
name=3D"testlogLog4jConfiguration">
=A0 =A0 <dep:attribute
name=3D"log4jFile">var/log/log4j.properties</dep:attribute&= gt;
=A0 <dep:reference
name=3D"ServerInfo"><dep:name>ServerInfo</dep:name>= ;</dep:reference>
=A0 <!--<dep:attribute
name=3D"log4jResource">META-INF/log4j.properties</dep:attri= bute>-->
=A0 </dep:gbean>

it works well.

I looked into ApplicationLog4jConfigurationGBean code:
...
InputStream in;
=A0 =A0 =A0 if (log4jFile !=3D null) {
=A0 =A0 =A0 =A0 =A0 File file =3D serverInfo.resolveServer(log4jFile);
=A0 =A0 =A0 =A0 =A0 in =3D new FileInputStream(file);
=A0 =A0 =A0 } else if (log4jResource !=3D null) {
=A0 =A0 =A0 =A0 =A0 in =3D classloader.getResourceAsStream(log4jResource);=
=A0 =A0 =A0 =A0 =A0 if (in =3D=3D null) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new NullPointerException("No log4j = properties resource
found at " + log4jResource);
=A0 =A0 =A0 =A0 =A0 }
=A0 =A0 =A0 } else {
=A0 =A0 =A0 =A0 =A0 return;
=A0 =A0 =A0 }

...

in =3D classloader.getResourceAsStream(log4jResource);

ClassLoader will search this file from classpath, and my project structure<= br> is:

LogWeb
=A0 ---src(testlog.java
=A0 ---WebContent
=A0 =A0 =A0 =A0 META-INF(log4j.properties)
=A0 =A0 =A0 =A0 WEB-INF
=A0 =A0 =A0 =A0 index.jsp
=A0 ----

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

--000e0cd3108ac9830a046ea13b3f--