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 2005/02/15 18:19:52 UTC

JCL+Tomcat+Log4j related problems [Was: Debugging]

James,

Join the club of users been bitten by Jakarta Commons Logging and
its "smart" discovery process.

You did not specify which minor version of Tomcat 5.0 it was. Anyway,
if it is Tomcat 5.0.27 or later, then keep the commons-logging and
log4j jars in the following locations:

TOMCAT_HOME/bin/commons-logging-api.jar
TOMCAT_HOME/common/lib/log4j.jar
TOMCAT_HOME/common/lib/commons-logging.jar

remove all JCL jars from ./server/lib/.

Your web-apps MUST not contain copies of commons-logging*.jar. This is 
important.

The same applies to the Tomcat 5.5 series.

Let us know if it works. (It should.)

At 05:59 PM 2/15/2005, James Stauffer wrote:
>Ceki Gülcü <ce...@qos.ch> wrote:
> > Which version of log4j are you using?
>log4j 1.2.8
>
> > Where have you placed the file log4j.jar? Does your web-application's
> > WEB-INF/lib contain a copy of commons-logging.jar?
>common/lib
>No.
>
>log file locations:
>./bin/commons-logging-api.jar
>./common/lib/log4j.jar
>./server/lib/commons-logging-api.jar
>./server/lib/commons-logging.jar
>./webapps/wfds/WEB-INF/wfds-log4j.xml
>
>
>
>
>--
>James Stauffer
>http://www.geocities.com/stauffer_james/
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org

-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by James Stauffer <st...@gmail.com>.
On Tue, 15 Feb 2005 18:19:52 +0100, Ceki Gülcü <ce...@qos.ch> wrote:
> You did not specify which minor version of Tomcat 5.0 it was. Anyway,
> if it is Tomcat 5.0.27 or later, then keep the commons-logging and
> log4j jars in the following locations:

5.0.27.  I'll give that a try.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by James Stauffer <st...@gmail.com>.
More info:  I changed the Config servlet to write a few logs with
logger.debug and logger.error and that info gets to the files but not
anything besides that.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by James Stauffer <st...@gmail.com>.
Could the problem be that I called LogLog.debug before configure?

public class ConfigLog4jServlet extends HttpServlet {

    public void init() {
        String prefix =  getServletContext().getRealPath("/");
        String file = getInitParameter("log4j-init-file");
        String fullPath = prefix+file;
        LogLog.debug("fullPath: " + fullPath);
        // if the log4j-init-file is not set, then no point in trying
        if(file != null && file.length() > 0) {
            DOMConfigurator.configure(fullPath);
        }
        Logger logger = Logger.getLogger(ConfigLog4jServlet.class);
        logger.error("Test Error");
    }

    public void print

    public void doGet(HttpServletRequest req, HttpServletResponse res) {
    }
}



On Tue, 15 Feb 2005 13:19:15 -0600, James Stauffer
<st...@gmail.com> wrote:
> Ceki Gülcü <ce...@qos.ch> wrote:
> > Place  commons-logging.jar and log4j.jar on the CLASSPATH by modifying
> > catalina.sh. Make sure that no other copy of commons-logging.jar
> > or  commons-logging-api.jar or log4j exists in your system visible to Tomcat.
> >
> > Try that and see what happens.
> 
> CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar:"$CATALINA_HOME"/common/lib/commons-logging.jar:"$CATALINA_HOME"/common/lib/log4j.jar
> 
> ./bin/commons-logging-api.jar
> ./common/lib/log4j.jar
> ./common/lib/commons-logging.jar
> ./webapps/wfds/WEB-INF/wfds-log4j.xml
> 
> Thanks for all of your help!
> 
> Would the following cause problems?
> /usr/share/java/commons-logging.jar
> /usr/share/java/commons-logging-1.0.2.jar
> /usr/share/ant/lib/commons-logging.jar
> 
> --
> James Stauffer
> http://www.geocities.com/stauffer_james/
> 


-- 
James Stauffer
http://www.geocities.com/stauffer_james/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by James Stauffer <st...@gmail.com>.
With a lot of help from Ceki we finally got it to work.  He helped me
find that the issue was that commons logging wasn't finding log4j. 
Upgrading (from 1.0.2) to 1.0.4 fixed the problem!  Version 1.0.2
apparently came with Tomcat 5.0.27.

Thanks Ceki!

-- 
James Stauffer
http://www.geocities.com/stauffer_james/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by James Stauffer <st...@gmail.com>.
Ceki Gülcü <ce...@qos.ch> wrote:
> The other (preferred) setting is:
> CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar:"
> 
> ./bin/commons-logging-api.jar
> ./common/lib/log4j.jar
> ./common/lib/commons-logging.jar

I changed to the preferred setting and it still doesn't work.

-- 
James Stauffer
http://www.geocities.com/stauffer_james/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by Ceki Gülcü <ce...@qos.ch>.
James,

The fact that the setup you describe works is just happenstance.

One setting I suggested was:

CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging.jar:"$CATALINA_HOME"/bin/log4j.jar

With NO copies of commons-logging.jar or log4j.jar in commons/lib.

The other (preferred) setting is:

CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar:"

./bin/commons-logging-api.jar
./common/lib/log4j.jar
./common/lib/commons-logging.jar

JCL can cause your application to fail in new and original ways. The 
settings above are known to work while many other seemingly equivalent 
configurations fail in more or less obvious ways. (The less obvious the 
failure the harder will be to hunt down.)

More below.

At 08:19 PM 2/15/2005, James Stauffer wrote:
>Ceki Gülcü <ce...@qos.ch> wrote:
> > Place  commons-logging.jar and log4j.jar on the CLASSPATH by modifying
> > catalina.sh. Make sure that no other copy of commons-logging.jar
> > or  commons-logging-api.jar or log4j exists in your system visible to 
> Tomcat.
> >
> > Try that and see what happens.
>
>CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar:"$CATALINA_HOME"/common/lib/commons-logging.jar:"$CATALINA_HOME"/common/lib/log4j.jar
>
>./bin/commons-logging-api.jar
>./common/lib/log4j.jar
>./common/lib/commons-logging.jar
>./webapps/wfds/WEB-INF/wfds-log4j.xml
>
>Thanks for all of your help!
>
>Would the following cause problems?
>/usr/share/java/commons-logging.jar
>/usr/share/java/commons-logging-1.0.2.jar
>/usr/share/ant/lib/commons-logging.jar

As long as the above jar files are not picked up by Tomcat they won't cause 
harm.

>--
>James Stauffer
>http://www.geocities.com/stauffer_james/

-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by James Stauffer <st...@gmail.com>.
Ceki Gülcü <ce...@qos.ch> wrote:
> Place  commons-logging.jar and log4j.jar on the CLASSPATH by modifying
> catalina.sh. Make sure that no other copy of commons-logging.jar
> or  commons-logging-api.jar or log4j exists in your system visible to Tomcat.
> 
> Try that and see what happens.

CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar:"$CATALINA_HOME"/common/lib/commons-logging.jar:"$CATALINA_HOME"/common/lib/log4j.jar

./bin/commons-logging-api.jar
./common/lib/log4j.jar
./common/lib/commons-logging.jar
./webapps/wfds/WEB-INF/wfds-log4j.xml

Thanks for all of your help!

Would the following cause problems?
/usr/share/java/commons-logging.jar
/usr/share/java/commons-logging-1.0.2.jar
/usr/share/ant/lib/commons-logging.jar

-- 
James Stauffer
http://www.geocities.com/stauffer_james/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by Ceki Gülcü <ce...@qos.ch>.
At 07:52 PM 2/15/2005, James Stauffer wrote:
>On Tue, 15 Feb 2005 19:47:56 +0100, Ceki Gülcü <ce...@qos.ch> wrote:
> >
> > The most basic thing you could try is to place log4j
>What?

Please ignore my comment above.


> > I'd place commons-logging.jar and log4j.jar on the CLASSPATH by modifying
> > catalina.sh and see what happens. Note that there must be no other copies
> > of commons-logging.jar and log4j.jar anywhere else, not in Tomcat and not
> > in the WEB-INF/lib directory of your web-apps.
>So are you suggesting that or only suggesting it if
>org.apache.commons.logging.LogFactory is set?

You are trying to give hints to JCL by setting the LogFactory system 
property. Don't ever do that. It will just cause Tomcat to crash.

Place  commons-logging.jar and log4j.jar on the CLASSPATH by modifying 
catalina.sh. Make sure that no other copy of commons-logging.jar 
or  commons-logging-api.jar or log4j exists in your system visible to Tomcat.

Try that and see what happens.

-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by James Stauffer <st...@gmail.com>.
On Tue, 15 Feb 2005 19:47:56 +0100, Ceki Gülcü <ce...@qos.ch> wrote:
> 
> The most basic thing you could try is to place log4j
What?

> I'd place commons-logging.jar and log4j.jar on the CLASSPATH by modifying
> catalina.sh and see what happens. Note that there must be no other copies
> of commons-logging.jar and log4j.jar anywhere else, not in Tomcat and not
> in the WEB-INF/lib directory of your web-apps.
So are you suggesting that or only suggesting it if
org.apache.commons.logging.LogFactory is set?

> I'm very surprised that the following set up did not work.
> 
>   TOMCAT_HOME/bin/commons-logging-api.jar
>   TOMCAT_HOME/common/lib/log4j.jar
>   TOMCAT_HOME/common/lib/commons-logging.jar
AFAIK that is what I had. :-/

> Did you have the org.apache.commons.logging.LogFactory system property set?
> It should not be set.
I just tried it that way once to see if it would work.

-- 
James Stauffer
http://www.geocities.com/stauffer_james/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by Ceki Gülcü <ce...@qos.ch>.
The most basic thing you could try is to place log4j

At 07:37 PM 2/15/2005, you wrote:
>If I add 
>-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jFactory

That won't work because the commons-logging-api.jar placed on the system 
CLASSPATH (catalina.sh adds bin/commons-logging-api.jar on teh system 
CLASSPATH) will not be able to find Log4jFactory because it is not included 
in commons-logging-api.jar. This in turn will prevent Tomcat from starting.

I'd place commons-logging.jar and log4j.jar on the CLASSPATH by modifying 
catalina.sh and see what happens. Note that there must be no other copies 
of commons-logging.jar and log4j.jar anywhere else, not in Tomcat and not 
in the WEB-INF/lib directory of your web-apps.

I'm very surprised that the following set up did not work.

  TOMCAT_HOME/bin/commons-logging-api.jar
  TOMCAT_HOME/common/lib/log4j.jar
  TOMCAT_HOME/common/lib/commons-logging.jar

Did you have the org.apache.commons.logging.LogFactory system property set? 
It should not be set.

>then catalina.out says the following. Do I need to add
>commons-logging.jar to the classpath?
>
>Bootstrap: Class loader creation threw exception
>java.lang.ExceptionInInitializerError
>         at 
> org.apache.catalina.loader.StandardClassLoader.<clinit>(StandardClassLoader.java:207)
>         at 
> org.apache.catalina.startup.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:189)
>         at 
> org.apache.catalina.startup.Bootstrap.createClassLoader(Bootstrap.java:160)
>         at 
> org.apache.catalina.startup.Bootstrap.initClassLoaders(Bootstrap.java:104)
>         at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:193)
>         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:399)
>Caused by: org.apache.commons.logging.LogConfigurationException:
>java.lang.ClassNotFoundException:
>org.apache.commons.logging.impl.Log4jFactory (Caused by
>java.lang.ClassNotFoundException:
>org.apache.commons.logging.impl.Log4jFactory)
>         at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:579)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at 
> org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:517)
>         at 
> org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:254)
>         at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
>         at 
> org.apache.tomcat.util.compat.JdkCompat.<clinit>(JdkCompat.java:55)
>         ... 6 more
>Caused by: java.lang.ClassNotFoundException:
>org.apache.commons.logging.impl.Log4jFactory
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>         at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:530)
>         ... 11 more

-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by James Stauffer <st...@gmail.com>.
If I add -Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jFactory
then catalina.out says the following. Do I need to add
commons-logging.jar to the classpath?

Bootstrap: Class loader creation threw exception
java.lang.ExceptionInInitializerError
	at org.apache.catalina.loader.StandardClassLoader.<clinit>(StandardClassLoader.java:207)
	at org.apache.catalina.startup.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:189)
	at org.apache.catalina.startup.Bootstrap.createClassLoader(Bootstrap.java:160)
	at org.apache.catalina.startup.Bootstrap.initClassLoaders(Bootstrap.java:104)
	at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:193)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:399)
Caused by: org.apache.commons.logging.LogConfigurationException:
java.lang.ClassNotFoundException:
org.apache.commons.logging.impl.Log4jFactory (Caused by
java.lang.ClassNotFoundException:
org.apache.commons.logging.impl.Log4jFactory)
	at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:579)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:517)
	at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:254)
	at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
	at org.apache.tomcat.util.compat.JdkCompat.<clinit>(JdkCompat.java:55)
	... 6 more
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.logging.impl.Log4jFactory
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:530)
	... 11 more



On Tue, 15 Feb 2005 12:27:01 -0600, James Stauffer
<st...@gmail.com> wrote:
> Ceki Gülcü <ce...@qos.ch> wrote:
> > What does TOMCAT_HOME/log/catalina.out say?
> Do you want me to send you the whole file?  Should I send it to you directly?
> 
> I also used the JSP at
> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4j-user@jakarta.apache.org&msgId=499567
> to check the config and it looks correct.
> 
> --
> James Stauffer
> http://www.geocities.com/stauffer_james/
> 


-- 
James Stauffer
http://www.geocities.com/stauffer_james/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by James Stauffer <st...@gmail.com>.
Ceki Gülcü <ce...@qos.ch> wrote:
> What does TOMCAT_HOME/log/catalina.out say?
Do you want me to send you the whole file?  Should I send it to you directly?

I also used the JSP at
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4j-user@jakarta.apache.org&msgId=499567
to check the config and it looks correct.

-- 
James Stauffer
http://www.geocities.com/stauffer_james/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by Ceki Gülcü <ce...@qos.ch>.
At 06:50 PM 2/15/2005, you wrote:
>Ceki Gülcü <ce...@qos.ch> wrote:
> > Join the club of users been bitten by Jakarta Commons Logging and
> > its "smart" discovery process.
> >
> > You did not specify which minor version of Tomcat 5.0 it was.
>5.0.27
>
> > Anyway, if it is Tomcat 5.0.27 or later, then keep the commons-logging and
> > log4j jars in the following locations:
> >
> > TOMCAT_HOME/bin/commons-logging-api.jar
> > TOMCAT_HOME/common/lib/log4j.jar
> > TOMCAT_HOME/common/lib/commons-logging.jar
> >
> > remove all JCL jars from ./server/lib/.
> >
> > Your web-apps MUST not contain copies of commons-logging*.jar. This is
> > important.
> >
> > The same applies to the Tomcat 5.5 series.
> >
> > Let us know if it works. (It should.)
>
>It has the same result. :-( What other info can I provide?

What does TOMCAT_HOME/log/catalina.out say?





-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: JCL+Tomcat+Log4j related problems [Was: Debugging]

Posted by James Stauffer <st...@gmail.com>.
Ceki Gülcü <ce...@qos.ch> wrote:
> Join the club of users been bitten by Jakarta Commons Logging and
> its "smart" discovery process.
> 
> You did not specify which minor version of Tomcat 5.0 it was.
5.0.27

> Anyway, if it is Tomcat 5.0.27 or later, then keep the commons-logging and
> log4j jars in the following locations:
> 
> TOMCAT_HOME/bin/commons-logging-api.jar
> TOMCAT_HOME/common/lib/log4j.jar
> TOMCAT_HOME/common/lib/commons-logging.jar
> 
> remove all JCL jars from ./server/lib/.
> 
> Your web-apps MUST not contain copies of commons-logging*.jar. This is
> important.
> 
> The same applies to the Tomcat 5.5 series.
> 
> Let us know if it works. (It should.)

It has the same result. :-( What other info can I provide?

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org