You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Galbreath <ma...@qat.com> on 2003/05/07 16:52:04 UTC

RE: Oh where, oh where has my little log gone? - solved

FWIT to JRun 4.0 users, there is apparently a class loader conflict between
ActionServlet and log4j.Layout.  I took the log4j.jar file out of
WEB-INF/lib and placed it in the %JRUN_HOME%/servers/lib directory and
everything began working.  Strange...I had to do the same thing yesterday
with xerces.jar before I could get another app I'm working on to go.
Apparently, this is a JRun idiosyncrasy.  I wonder if validator.jar suffers
the same "feature?"

Mark

-----Original Message-----
From: Mark Galbreath [mailto:mark_galbreath@qat.com] 
Sent: Wednesday, May 07, 2003 10:40 AM
To: 'Struts Users Mailing List'
Subject: RE: Oh where, oh where has my little log gone?


Makes perfect sense, Tim, and I pretty much guessed that.  I have the
log4j.jar in my system classpath and physically located in WEB-INF/lib. I
built a new jar from the latest download (1.2.8), and the only
log4j.properties file I can find is in one of the examples subdirectories
and contains only

log4j.rootCategory=, A1 log4j.appender.A1=org.apache.log4j.lf5.LF5Appender
log4j.appender.A1.MaxNumberOfRecords=1000

I can find no log4j.xml anywhere.

And still I'm getting a NoClassDefFoundError for org/apache/log4j/Layout
that prevents the Action servlet from loading on container startup:

05/07 10:35:48 user JSPServlet: init
05/07 10:35:49 error Could not pre-load servlet: action
java.lang.NoClassDefFoundError: org/apache/log4j/Layout
        at
org.apache.commons.logging.impl.Log4jFactory.getInstance(Log4jFactory.java:1
40)
        at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.ja
va:255)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:390)
        at
org.apache.struts.action.ActionServlet.<clinit>(ActionServlet.java:376)
        at java.lang.Class.newInstance0(Native Method)
        at java.lang.Class.newInstance(Class.java:232)
        at
jrun.servlet.WebApplicationService.loadServlet(WebApplicationService.java:11
92)
        at
jrun.servlet.WebApplicationService.preloadServlets(WebApplicationService.jav
a:762)
        at
jrun.servlet.WebApplicationService.postStart(WebApplicationService.java:257)
        at
jrun.deployment.DeployerService.initModules(DeployerService.java:711)
        at
jrun.deployment.DeployerService.createWatchedDeployment(DeployerService.java
:242)
        at jrun.deployment.DeployerService.deploy(DeployerService.java:430)
        at
jrun.deployment.DeployerService.checkWatchedDirectories(DeployerService.java
:179)
        at jrun.deployment.DeployerService.run(DeployerService.java:891)
        at
jrunx.scheduler.SchedulerService.invokeRunnable(SchedulerService.java:223)
        at
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451
)
        at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

Is there a class loader issue I am being ignorant of?  It looks to me that
commons-logging is trying to instantiate Layout but for some reason cannot
find the path that percolates up to ActionServlet.

Mark

-----Original Message-----
From: Chen, Gin [mailto:Gin.Chen@NielsenMedia.com] 
Sent: Wednesday, May 07, 2003 9:51 AM
To: 'Struts Users Mailing List'
Subject: RE: Oh where, oh where has my little log gone?


That's not how it works Mark.
It will simply log it to the location you specified in your log4j.properties
or log4j.xml for the class that you created the Log for. If you don't define
a location then it goes to the default logging location (look in
log4j.properties or log4j.xml to see where that is). So in first question:

> private Log log = LogFactory.getLog( "com.qat.expense" );

Simply creates a log object (not a physical file) that says, anything that
is .debug .error etc to me will go to the log location that is defined for
com.qat.expense (again in ur log4j conf). If there is nothing defined for
that classpath then just write it to the default logging location. Btw,
log.error( "ExpenseAction", e ); just defines a line in the log that says
ExpenseAction and then the stack trace for ur exception. It's about the same
as (not exactly but close) printing out:

System.err.println("ExpenseAction: " + e.toString()); e.printStackTrace(
System.err );

Hope that makes sense.
-Tim

-----Original Message-----
From: Mark Galbreath [mailto:mark_galbreath@qat.com]
Sent: Wednesday, May 07, 2003 9:39 AM
To: 'Struts Users Mailing List'
Subject: RE: Oh where, oh where has my little log gone?


yep, I'm invoking the log as:

try {
    fltTaxi_limo_total += new Float( taxi_limo[ i ] ).floatValue();

} catch( NumberFormatException e ) {
    log.error( "ExpenseAction", e );
}

and I can see the exception being thrown to the container (stdout) log when
I make the try fail, but no log called "com.qat.expense" nor any entry
prefixed with "ExpenseAction,"  which is how I intuitively believe this
works.  Of course, that could be the problem in itself..... :-(

Mark

-----Original Message-----
From: Wendy Smoak [mailto:Wendy.Smoak@asu.edu] 
Sent: Tuesday, May 06, 2003 6:13 PM
To: 'Struts Users Mailing List'
Subject: RE: Oh where, oh where has my little log gone?


> Where does Struts put this:
> private Log log = LogFactory.getLog( "com.qat.expense" ); defined in 
> one of my action classes and invoked in a catch()?

Put what?  That just creates a "Log" object.  Are you also writing to it, as
with:
   log.debug( "Something bad happened!" );
?

That's when I would expect something visible to happen.  This isn't really
Struts at work, though, it's Commons Logging.
(http://jakarta.apache.org/commons/logging/index.html)  I think it writes to
system.err if you don't do any configuration at all.  Assuming you're using
Tomcat, check the console, the catalina.out file or the localhost_log file
for the correct date.

If you don't see your log message, and you're sure the log.debug() statement
is being called, I'd log a very unique string of text and then grep (or
search) through everything to find out what file it landed in.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management




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

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




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



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