logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedetta Barbieri" <bbarbi...@dianoema.it>
Subject RE: Re[4]: logger not working with servlet
Date Fri, 07 Jun 2002 09:24:49 GMT
Hi Jake,
I solved my problem, I had mispelled the JDBCAppender full name (wrote
org.apache.log4j.JDBCAppender instead of org.apache.log4j.jdbc.JDBCAppender)

Benedetta

-----Original Message-----
From: Jacob Kjome [mailto:hoju@visi.com]
Sent: giovedi 6 giugno 2002 17.37
To: Log4J Users List
Subject: Re[4]: logger not working with servlet


Hello Benedetta,

What servlet engine are you using?  Version?

Where do you put Log4j?  It really needs to be in the WEB-INF/lib of
each webapp using logging and *not* in something like $TOMCAT_HOME/lib
where one Log4j instance is available to all contexts.

Jake

Thursday, June 06, 2002, 4:31:19 AM, you wrote:

BB> I tried your example, I got the error

BB> log4j:ERROR Could not instantiate class [JDBCAppender].
BB> java.lang.ClassNotFoundException: JDBCAppender

BB> in the servlet Log4jInit.

BB> I'm using log4j 1.2.3 and I have put it among the libraries of my
project

BB> The properties file is read fine.

BB> What could be wrong?

BB> Thanks

BB> Benedetta

BB> -----Original Message-----
BB> From: Jacob Kjome [mailto:hoju@visi.com]
BB> Sent: mercoledi 5 giugno 2002 17.52
BB> To: Log4J Users List
BB> Subject: Re[2]: logger not working with servlet


BB> Hello Peter,

BB> Well, here's an example that I added to the open source Barracuda
project (
BB> http://barracuda.enhydra.org/ ).  I'm attaching a zip file that
BB> includes the web.xml and the Log4jInit servlet that the Barracuda
BB> project uses.  The nice thing with this servlet is that is sets up
BB> Log4j using configureAndWatch() if it is able to use an absolute file
BB> path (ie... it isn't working straight out of a .war file, rather it is
BB> running from a directory on the file system).  If it is running from a
BB> .war file, it loads it via URL...and if it can't find the file in the
BB> specified location, it just lets Log4j set itself up (assuming you put
BB> log4j.properties or log4j.xml in WEB-INF/classes).

BB> Hope this helps,

BB> P.S.  If you want to see the example working, go grab the latest cvs
from
BB> the Baracuda project, build, and set up Barracuda with Tomcat.

BB> Jake

BB> Wednesday, June 05, 2002, 8:58:25 AM, you wrote:

PC>> i followed the instruction from the log4j documentation and put in my
PC>> web.xml file the following for the servlet:


PC>>      <servlet>
PC>>        <servlet-name>TallyTeset</servlet-name>
PC>>        <servlet-class>roster.TallyTest</servlet-class>
PC>>        <init-param>
PC>>           <param-name>log4j-init-file</param-name>
PC>>
BB> <param-value>WEB-INF/classes/roster/log4j-ct.prop</param-value>
PC>>        </init-param>
PC>>        <load-on-startup>1</load-on-startup>
PC>>      </servlet>

PC>> and i use the following code to read the properties file:

PC>>          public void init(ServletConfig config) throws
ServletException{
PC>>                  super.init(config);
PC>>                  prefix = getServletContext().getRealPath("/");
PC>>                  file = getInitParameter("log4j-init-file");
PC>>                  System.out.println("Prefix: " + prefix);
PC>>                  System.out.println("File: " + file);
PC>>          }

PC>> put looking at it the getInitParameter() method isn't reading the
PC>> initialization from the web.xml.  is that correct?  i thought it would
BB> read
PC>> it from the web.xml file.

PC>> At 09:48 AM 6/5/2002, Ted Velkoff wrote:
>>>The problem is not in the property file, but rather that the servlet
BB> doesn't
>>>know where to find the property file.
>>>
>>>There are two parts - making sure the servlet reads the file, and second,
>>>telling the servlet where to look.
>>>
>>>1) This tells the configurator to read the property file when the servlet
BB> is
>>>started
>>>
>>>public init() {
>>>   ...
>>>   PropertyConfigurator.configure(filename);
>>>   ...
>>>}
>>>
>>>2) But where does filename come from?  This can be a headache, but one
>>>solution is to put it relative to some location you can easily find from
>>>your servlet container.  In websphere, there's a system property
>>>"server.root".  Either the same exists for Tomcat or something similar.
>>>Anyway...
>>>
>>>public init() {
>>>   ...
>>>   String filename = System.getProperty("server.root") + File.separator +
>>>"log.properties"
>>>   ...  // where "log.properties" is the name of your log4j property
file.
>>>   ...  // of course you could have some intermediate directories under
>>>server.root...
>>>   PropertyConfigurator.configure(filename);
>>>   ...
>>>}
>>>
>>>
>>>
>>>
>>>-----Original Message-----
>>>From: Peter Choe [mailto:choepete@mindspring.com]
>>>Sent: Wednesday, June 05, 2002 9:31 AM
>>>To: log4j-user@jakarta.apache.org
>>>Subject: logger not working with servlet
>>>
>>>
>>>i am trying to log4j to work with a servlet on tomcat4.0 and java1.4 on a
>>>solaris intel machine.  but when i try to call the servlet to get it to
>>>log, i get the following message:
>>>
>>>log4j:WARN No appenders could be found for logger (roster.TallyTest).
>>>log4j:WARN Please initialize the log4j system properly.
>>>
>>>this is my log property file:
>>>
>>>log4j.rootLogger=debug, A1, R
>>>
>>>log4j.appender.A1=org.apache.log4j.ConsoleAppender
>>>
>>>log4j.appender.A1.layout=org.apache.log4j.PatternLayout
>>>log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
>>>
>>>log4j.appender.R=org.apache.log4j.RollingFileAppender
>>>log4j.appender.R.File=/export/home/tomcat/logs/coursetally.log
>>>log4j.appender.R.MaxFileSize=100KB
>>>log4j.appender.R.MaxBackupIndex=1
>>>
>>>log4j.appender.R.layout=org.apache.log4j.PatternLayout
>>>log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
>>>~
>>>
>>>any suggestions on why it isn't working for my servlets, but works for
>>>stand alone java applications?
>>>
>>>Peter Choe
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:
BB> <mailto:log4j-user-unsubscribe@jakarta.apache.org>
>>>For additional commands, e-mail:
BB> <mailto:log4j-user-help@jakarta.apache.org>

PC>> Peter Choe


PC>> --
PC>> To unsubscribe, e-mail:
BB> <mailto:log4j-user-unsubscribe@jakarta.apache.org>
PC>> For additional commands, e-mail:
BB> <mailto:log4j-user-help@jakarta.apache.org>



BB> --
BB> Best regards,
BB>  Jacob                            mailto:hoju@visi.com




BB> --
BB> To unsubscribe, e-mail:
<mailto:log4j-user-unsubscribe@jakarta.apache.org>
BB> For additional commands, e-mail:
<mailto:log4j-user-help@jakarta.apache.org>



--
Best regards,
 Jacob                            mailto:hoju@visi.com


--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>







--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message