Thorbjørn Ravn Andersen | 2 Jan 15:42 2004
Picon

Is there a way to make Eclipse recognize log4j messages in its console buffer and hyperlink to the statement that created it?

We use Eclipse for development and I like the way that stacktraces are 
shown and linked to the underlying source, so I was pondering whether 
similar functionality is possible for the numerous debug messages we 
have?  I looked at the Ganymede plugin, but it requires an alternate 
log4j configuration, which I would prefer not to have.

Is there other approaches for this?  Or should I look into conditional 
configuration files?

--

-- 
  Thorbjoern Ravn Andersen      "...plus...Tubular Bells!"
Ralf Schneider | 4 Jan 21:18 2004
Picon

NoClassDefFoundError: org/apache/log4j/Logger


I get the above error message when starting Tomcat 5.0.7 (which comes with 
JWSDP 1.3 from Sun) inside Eclipse. I put log4j-1.2.8.jar into the 
WEB-INF/lib directory of my web application and added the JAR-file to the 
"Java Build Path" property of my Java project. When I compile the project 
everything works fine. No error messages. But when I start Tomcat I get the 
above error message. 

A friend told me that the described procedure worked for him with a 
"standalone" Tomcat 4.1.27. Are there any problems with the Tomcat version 
that comes with JWSDP 1.3?

Any ideas what might be the problem?

Best regards,
Ralf.
Jacob Kjome | 4 Jan 23:28 2004

Re: NoClassDefFoundError: org/apache/log4j/Logger

I smell commons-logging somehow finding log4j in a different classloader 
(WEB-INF/lib) and trying to use it in another classloader.  I won't 
speculate as to exactly how it accomplishes this feat, but it is almost 
definitely commons-logging's fault.  Anyway, try adding log4j.jar to 
CATALINA_HOME/common/lib.  You might also want to add a log4j.xml file in 
common/classes which simply supplies a console appender.  Then to make sure 
app logging is separated, either put log4j.jar in each app's WEB-INF/lib 
and/or use a custom repository selector.

Jake

At 09:18 PM 1/4/2004 +0100, you wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>I get the above error message when starting Tomcat 5.0.7 (which comes with
>JWSDP 1.3 from Sun) inside Eclipse. I put log4j-1.2.8.jar into the
>WEB-INF/lib directory of my web application and added the JAR-file to the
>"Java Build Path" property of my Java project. When I compile the project
>everything works fine. No error messages. But when I start Tomcat I get the
>above error message.
>
>A friend told me that the described procedure worked for him with a
>"standalone" Tomcat 4.1.27. Are there any problems with the Tomcat version
>that comes with JWSDP 1.3?
>
>Any ideas what might be the problem?
>
>Best regards,
>Ralf.
(Continue reading)

Eric Bessette | 4 Jan 22:03 2004

org.apache.log4j.spi.ThrowableInformation hiding root cause, PLEASE HELP

First off, I'm not sure if this is a tomcat or log4j issue, so I'm posting
to both lists.

Many times when I have an error in my jsp code, I only get the stack trace
below in my log4j log file.  I'm assuming the root exception is there
somewhere, but how do I get it to display?

SEVERE: Servlet.service() for servlet jsp threw exception
javax.servlet.ServletException: org.apache.log4j.spi.ThrowableInformation
	at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:680)
	at org.apache.jsp.home.temp_jsp._jspService(temp_jsp.java:75)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
20)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:288)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:263)
(Continue reading)

Wendy Smoak | 5 Jan 19:30 2004
Picon

Help with replacing tokens for log file name


I'm not sure whether this is more Ant or Log4j, so please send me along
if I'm not in the right place.

In build.xml, I have this:
   <target name="props-dev" depends="copy-props">
     <replace file="${propsdir}/log4j.properties" 
                token=" <at> logFileName <at> " 
                value="${env.TOMCAT_HOME}\logs\${context}.log"/>
   </target>

It's turning this in log4j.properties:
   log4j.appender.daily.File= <at> logFileName <at> 
into this:

log4j.appender.daily.File=c:\jakarta\jakarta-tomcat-4.1.29\logs\coldev.l
og

Unfortunately, this results in log messages going to a file called
   jakartajakarta-tomcat-4.1.29logscoldev.log
in the c:\jakarta\jakarta-tomcat-4.1.29\bin directory.

I tried quoting   <at> logFileName <at>  but that produced:
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException:
"c:jakartajakarta-tomcat-4.1.29logscoldev.log" (T
he filename, directory name, or volume label syntax is incorrect)
when the webapp is started.

I think the answer is to escape the backslashes, but since part of it
(Continue reading)

Shapira, Yoav | 5 Jan 19:35 2004

RE: Help with replacing tokens for log file name


Howdy,
Good question.  I don't know the answer, as I have "hard-coded"
properties file for development, staging, testing, production, etc.
(build.properties files), and then it's much simpler.  I do this because
I intensely dislike making any aspect of build or deployment dependent
on environment variables.  If you still want to pursue this route, I
suggest asking on the ant-user list how to escape properties.  Something
like an in-memory FixCRLF task.

Yoav Shapira
Millennium ChemInformatics

>-----Original Message-----
>From: Wendy Smoak [mailto:Wendy.Smoak <at> asu.edu]
>Sent: Monday, January 05, 2004 1:30 PM
>To: log4j-user <at> logging.apache.org
>Subject: Help with replacing tokens for log file name
>
>
>I'm not sure whether this is more Ant or Log4j, so please send me along
>if I'm not in the right place.
>
>In build.xml, I have this:
>   <target name="props-dev" depends="copy-props">
>     <replace file="${propsdir}/log4j.properties"
>                token=" <at> logFileName <at> "
>                value="${env.TOMCAT_HOME}\logs\${context}.log"/>
>   </target>
>
(Continue reading)

Ceki Gülcü | 5 Jan 19:41 2004
Picon

Re: Help with replacing tokens for log file name


Have you considered using forward slashes? For example:
c:\\xyz\\foo.bar and c:/xyz/foo.bar should be interpreted as the same
file even on windows.

At 11:30 AM 1/5/2004 -0700, Wendy Smoak wrote:

>I'm not sure whether this is more Ant or Log4j, so please send me along
>if I'm not in the right place.
>
>In build.xml, I have this:
>    <target name="props-dev" depends="copy-props">
>      <replace file="${propsdir}/log4j.properties"
>                 token=" <at> logFileName <at> "
>                 value="${env.TOMCAT_HOME}\logs\${context}.log"/>
>    </target>
>
>It's turning this in log4j.properties:
>    log4j.appender.daily.File= <at> logFileName <at> 
>into this:
>
>log4j.appender.daily.File=c:\jakarta\jakarta-tomcat-4.1.29\logs\coldev.l
>og
>
>Unfortunately, this results in log messages going to a file called
>    jakartajakarta-tomcat-4.1.29logscoldev.log
>in the c:\jakarta\jakarta-tomcat-4.1.29\bin directory.
>
>I tried quoting   <at> logFileName <at>  but that produced:
>log4j:ERROR setFile(null,true) call failed.
(Continue reading)

Wendy Smoak | 5 Jan 21:34 2004
Picon

RE: Help with replacing tokens for log file name

> From: Ceki Gülcü [mailto:ceki <at> qos.ch] 
> Have you considered using forward slashes? For example:
> c:\\xyz\\foo.bar and c:/xyz/foo.bar should be interpreted as the same
> file even on windows.

I would... but part of it comes from a system property and I don't want to have to remember "Oh, yeah,
Ant/Log4j won't work unless I use forward slashes here" the next time I upgrade Tomcat.

I think I'll just have a dev.properties file that holds the location of the log file for development, in
addition to the war.properties that holds the location for when I build the war file.  

Thanks!  I often make things FAR more difficult than they need to be, just wanted to check that I wasn't
missing something simple.

--

-- 
Wendy Smoak
Application Systems Analyst, Sr.
ASU IA Information Resources Management 
anguyen | 5 Jan 21:37 2004

Problems with DOMConfigurator and WebLogic 6.1 SP4

I am using log4j 1.2.7 with a web application under WebLogic 6.1 sp4.  I
just recently switched from using log4j.properties to log4j.xml in order to
use an asynchronous appender.  I'm running into a problem that I hope
someone on this list can help me with.

The first class that accesses log4j is a ServletContextListener.  My
getLogger call is failing:

private static final Logger log =
Logger.getLogger(MyServletContextListener.class);

I've turned on log4j.debug, and here's what I get in my console output:

--BEGIN CONSOLE OUTPUT--
log4j: Trying to find [log4j.xml] using context classloader
sun.misc.Launcher$AppClassLoader <at> 3f52a5.
log4j: Trying to find [log4j.xml] using
weblogic.utils.classloaders.ChangeAwareClassLoader <at> 3f61a0 finder:
weblogic.utils.classloaders.MultiClassFinder <at> 596138 class loader.
log4j: Using URL
[file:/home/anguyen/applications/myapp//WEB-INF/classes/log4j.xml] for
automatic log4j configuration.
log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
log4j: System property is :null
java.lang.ExceptionInInitializerError: java.lang.ClassCastException:
weblogic.xml.jaxp.RegistryDocumentBuilderFactory
        at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown
Source)
        at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:644)
(Continue reading)

Jacob Kjome | 5 Jan 21:48 2004

RE: Help with replacing tokens for log file name

Quoting Wendy Smoak <Wendy.Smoak <at> asu.edu>:

> > From: Ceki Gülcü [mailto:ceki <at> qos.ch]
> > Have you considered using forward slashes? For example:
> > c:\\xyz\\foo.bar and c:/xyz/foo.bar should be interpreted as the same
> > file even on windows.
> 
> I would... but part of it comes from a system property and I don't want to
> have to remember "Oh, yeah, Ant/Log4j won't work unless I use forward slashes
> here" the next time I upgrade Tomcat.

No need to "remember" anything.  All you have to do is use <pathconvert>...

<pathconvert targetos="unix" property="log4j.log.path.unix">
    <path><pathelement location="${env.TOMCAT_HOME}/logs"/></path>
</pathconvert>

<replace file="${propsdir}/log4j.properties"
                 token=" <at> logFileName <at> "
                 value="${log4j.log.path.unix}/${context}.log"/>

The result will be...

log4j.appender.daily.File=c:/jakarta/jakarta-tomcat-4.1.29/logs/coldev.log

This will work whether building under Windows or Unix.

> 
> I think I'll just have a dev.properties file that holds the location of the
> log file for development, in addition to the war.properties that holds the
(Continue reading)


Gmane