You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Ceki Gülcü <ce...@qos.ch> on 2002/06/05 17:03:28 UTC

Re: log4j use in multiple tomcat web apps - properties file parsing errors

This is quite similar to the problem reported by Chris Goodall a few
hours ago.

First, here are the standard questions:

1) Which version of the JDK are you using?
2) Which version of log4j?

The warning message "object is not an instance of declaring class" is
not very helpful. In order to get to the root cause I'd like you to
modify setProperty(String name, String value) method in
src/java/org/apache/log4j/config/PropertySetter.java

  public
   void setProperty(String name, String value) {
     [snip]
     } else {
       try {
         setProperty(prop, name, value);
       } catch (PropertySetterException ex) {
          // before: LogLog.warn("Failed to set property [" + name +
          // before:     "] to value \"" + value + "\". " + ex.getMessage());
          // new:
          LogLog.warn("Failed to set property [" + name +
                     "] to value \"" + value + "\". ", ex.rootCause);
       }
     }
   }

}

This modification is slightly different than what I suggested to
Chris.

Compiling log4j should be easy. Download log4j version 1.2.3 from the
log4j site. Unzip it somewhere. Next, you will need is a recent
version of jakarta-ant.  Executing the command "ant jar" from the
log4j home directory should create a new jar file called
log4j-1.2.3.jar in the directory dist/lib/. This jar will not contain
support for JMX, JMS, SMTP etc. which are not necessary for our
purposes.

We can start hunting for the problem once we see the new error
message.  Shout if you need help with compiling log4j.


At 10:40 05.06.2002 -0400, PGuimaraes@genelogic.com wrote:
>Hi,
>
>I am running tomcat 4.0.1 on Solaris with two web applications.  I recently
>added log4j code to my applications, and after reading log4j's Short
>Manual,
>decided to set up my configuration to use an initialization servlet to
>initialize log4j, since that's the most flexible way to do it.  I put the
>log4j.jar file in the WEB-INF/lib directory of each web application.
>During
>tomcat's startup process (started with -Dlog4j.debug), the log4j.properties
>file for the first application is parsed successfully, but the
>log4j.properties
>file for the second application generates warning and error messages saying
>it failed to set a property because the "object is not an instance of
>declaring class".  More details follow.
>
>I first wrote the initialization servlet to set the system property
>log4j.configuration to the full path of my log4j.properties file, since
>that's the preferred way to specify the default initialization file,
>according to the Short Manual.  The log4j.properties file for each web
>application used the same appender name (logFile), but the File property
>of this appender (a DailyRollingFileAppender) was different for each web
>application.  Since tomcat's Class Loader HOW-TO says that each application
>gets its own class loader, I didn't think that using the same appender name
>for each application would cause any problems.  However, this configuration
>generated the errors mentioned above.
>
>In my search for a solution to this problem, I found the JGuru web page at
>http://www.jguru.com/forums/view.jsp?EID=801715.  Based on the postings on
>this page, I modified the log4j.properties file for each web application to
>use different appender names, instead of the same name.  I also modified my
>initializing servlet to call the PropertyConfigurator.configure method
>directly instead of relying on the automatic configuration from the
>log4j.configuration system property (see the last reply on that page).
>Unfortunately, this configuration generated the same warnings and errors.
>
>I have searched the user groups and FAQs quite extensively in the last
>couple of days, and tried everything I could think of (based on what I
>read), but I still have not been able to successfully configure log4j
>for multiple tomcat web applications (only two, in this case).
>
>I have attached the log4j.properties files for each of my two applications
>(they have been renamed so the names would be unique), the source code for
>the initializing servlet, a snippet of the web.xml file (same for both
>applications), and a snippet of the catalina.out log file listing the
>warning and error messages.  Maybe someone can spot a configuration error
>or some missing information.
>
>Any clue on how to solve this problem, or a pointer to what I should try
>next or where else to look for an answer would be greatly appreciated.
>
>Thanks,
>
>Pat
>
>Patricia T. Guimaraes
>Software Engineer
>Gene Logic, Inc.
>
>
>(See attached file: portal_log4j.properties)  (See attached file:
>analysis_log4j.properties)  (See attached file: Log4jInit.java)  (See
>attached file: web.xml)  (See attached file: catalina.out)
>
>
>
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>

--
Ceki

SUICIDE BOMBING - A CRIME AGAINST HUMANITY
Sign the petition: http://www.petitiononline.com/1234567b
I am signatory number 22106. What is your number?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>