You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Paul Hodgetts, Agile Logic" <ph...@agilelogic.com> on 2002/12/28 08:29:00 UTC

Problem Using Log4J and Commons Logging with Struts

Using the latest nightly build from 2002-12-27, the latest
Commons Logging nightly build from 2002-12-27, and Log4J
1.2.7...

I have Common Logging configured to use the SimpleLog, and
everything is working fine, with both my application and
Struts successfully logging to the simple log.

When I just drop log4j-1.2.7.jar into WEB-INF/lib,
regardless of whether I configure Commons Logging to use
the Log4JCategoryLog or not, I get this exception:

java.lang.NoClassDefFoundError: org/apache/log4j/Layout
         at org.apache.commons.logging.impl.Log4jFactory.getInstance(Log4jFactory.java:140)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:255)
         at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:390)
         at org.apache.struts.action.ActionServlet.<clinit>(ActionServlet.java:372)
[...]

I've been trying to follow the set up shown in Cavaness'
Programming Jakarta Struts book, chapter 15.  What am I
doing wrong?

Thanks,
Paul


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


Re: Problem Using Log4J and Commons Logging with Struts

Posted by Andreas Mack <va...@mediales.net>.
On Sat, 2002-12-28 at 08:29, Paul Hodgetts, Agile Logic wrote:
> Using the latest nightly build from 2002-12-27, the latest
> Commons Logging nightly build from 2002-12-27, and Log4J
> 1.2.7...
> 
> I have Common Logging configured to use the SimpleLog, and
> everything is working fine, with both my application and
> Struts successfully logging to the simple log.
> 
> When I just drop log4j-1.2.7.jar into WEB-INF/lib,
> regardless of whether I configure Commons Logging to use
> the Log4JCategoryLog or not, I get this exception:
> 

I've added this to my CATALINAOPTS:
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog

and have both working side by side quite well. Read the commons-logging
docs for other ways to initialize it.

HTH,
Andreas.

<offtopic-SCNR-remark>
In the HOLIDAY thread somebody said the reference "eye of the needle" by
Jesus is/was a gate or door and the point is humility. I have a
different take here based on the context: His disciples asked immediatly
after that "Then who can enter??" This sounds very much like disbelief,
like "then nobody can get in". Jesus answered sth like "It's impossible
for man, but nothing is impossible for God." To me this supports the
interpretation that "eye-of-needle" means a real small-thingie needle,
and the point here is grace primarily.
</Offtopic-SCNR-remark>
 

-- 
Andreas Mack <va...@mediales.net>
mediales. GmbH


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


RE: Problem Using Log4J and Commons Logging with Struts

Posted by Senthivel U S <se...@uaeexchange.com>.
Greetings,

We have added the two files in the WEB-INF/classes directory, still
the same problem. Any value  to be set in web.xml????

thanx,
u s sen


-----Original Message-----
From: Eddie Bush [mailto:ekbush@swbell.net] 
Sent: 28 12, 2002 12:44 PM
To: Struts Users Mailing List
Subject: Re: Problem Using Log4J and Commons Logging with Struts

Add two files to your WEB-INF/classes directory:

commons-logging.properties <==============================
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Lo
g4jFactory

log4j.properties <=======================================
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG,A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

That should fix things, I believe.  The commons-logging package is going

to expect that you want to use Log4J if you have the Log4J JAR in the 
classpath (ie your WEB-INF/lib directory).  It's not going to "work" 
correctly until you configure it properly though (at least, it never has

for me).

Good Luck!

Paul Hodgetts, Agile Logic wrote:

> Using the latest nightly build from 2002-12-27, the latest
> Commons Logging nightly build from 2002-12-27, and Log4J
> 1.2.7...
>
> I have Common Logging configured to use the SimpleLog, and
> everything is working fine, with both my application and
> Struts successfully logging to the simple log.
>
> When I just drop log4j-1.2.7.jar into WEB-INF/lib,
> regardless of whether I configure Commons Logging to use
> the Log4JCategoryLog or not, I get this exception:
>
> java.lang.NoClassDefFoundError: org/apache/log4j/Layout
>         at 
>
org.apache.commons.logging.impl.Log4jFactory.getInstance(Log4jFactory.ja
va:140) 
>
>         at 
>
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImp
l.java:255) 
>
>         at 
> org.apache.commons.logging.LogFactory.getLog(LogFactory.java:390)
>         at 
>
org.apache.struts.action.ActionServlet.<clinit>(ActionServlet.java:372)
> [...]
>
> I've been trying to follow the set up shown in Cavaness'
> Programming Jakarta Struts book, chapter 15.  What am I
> doing wrong?
>
> Thanks,
> Paul

-- 
Eddie Bush





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


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


Re: Problem Using Log4J and Commons Logging with Struts

Posted by Eddie Bush <ek...@swbell.net>.
Add two files to your WEB-INF/classes directory:

commons-logging.properties <==============================
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jFactory

log4j.properties <=======================================
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG,A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

That should fix things, I believe.  The commons-logging package is going 
to expect that you want to use Log4J if you have the Log4J JAR in the 
classpath (ie your WEB-INF/lib directory).  It's not going to "work" 
correctly until you configure it properly though (at least, it never has 
for me).

Good Luck!

Paul Hodgetts, Agile Logic wrote:

> Using the latest nightly build from 2002-12-27, the latest
> Commons Logging nightly build from 2002-12-27, and Log4J
> 1.2.7...
>
> I have Common Logging configured to use the SimpleLog, and
> everything is working fine, with both my application and
> Struts successfully logging to the simple log.
>
> When I just drop log4j-1.2.7.jar into WEB-INF/lib,
> regardless of whether I configure Commons Logging to use
> the Log4JCategoryLog or not, I get this exception:
>
> java.lang.NoClassDefFoundError: org/apache/log4j/Layout
>         at 
> org.apache.commons.logging.impl.Log4jFactory.getInstance(Log4jFactory.java:140) 
>
>         at 
> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:255) 
>
>         at 
> org.apache.commons.logging.LogFactory.getLog(LogFactory.java:390)
>         at 
> org.apache.struts.action.ActionServlet.<clinit>(ActionServlet.java:372)
> [...]
>
> I've been trying to follow the set up shown in Cavaness'
> Programming Jakarta Struts book, chapter 15.  What am I
> doing wrong?
>
> Thanks,
> Paul

-- 
Eddie Bush





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