You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Wendy Smoak <We...@asu.edu> on 2002/12/09 20:45:17 UTC

Tomcat + commons-logging + log4j

I need help with logging.  I have just today convinced commons-logging and
log4j to work together, and now I would like to do logging from my webapp.

My first question is whether I really need commons-logging and log4j at all.
I see that tomcat is already producing some logs in /path/to/tomcat/logs.
However, I can't figure out how to get one of those for my own webapp.  I
only see logs for admin, examples, and a generic log.  I have read 'The
Logger Component' in the docs, but it doesn't have any info on
configuration.  I don't see any references to logging in server.xml or the
global web.xml or the web.xml in the examples webapp.

If I do use commons-logging+log4j and want to write my own logs to that same
tomcat logs directory, what's the best [cross-platform] way to specify the
location?  I'm currently using:
   log4j.appender.rolling.File=../../../logs/myWebApp.log
which backs up out of WEB-INF/classes and moves down into the logs
directory.

I'm very new at this, so please tell me if I'm going about it all wrong!

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

Re: Tomcat + commons-logging + log4j

Posted by Dan Tran <da...@hotmail.com>.
Your way is working fine right now, so why changing it?

Use Tomcat log interface will make your code depending
on Tomcat appserver.  What if  you want run your app
on other servers in the future?

I just happen to move all logging to use common-log so that it will run on
multiple appservers.

Just my 2Cents advice

-Dan
----- Original Message -----
From: "Wendy Smoak" <We...@asu.edu>
To: "'Tomcat Users List'" <to...@jakarta.apache.org>
Sent: Monday, December 09, 2002 11:45 AM
Subject: Tomcat + commons-logging + log4j


>
> I need help with logging.  I have just today convinced commons-logging and
> log4j to work together, and now I would like to do logging from my webapp.
>
> My first question is whether I really need commons-logging and log4j at
all.
> I see that tomcat is already producing some logs in /path/to/tomcat/logs.
> However, I can't figure out how to get one of those for my own webapp.  I
> only see logs for admin, examples, and a generic log.  I have read 'The
> Logger Component' in the docs, but it doesn't have any info on
> configuration.  I don't see any references to logging in server.xml or the
> global web.xml or the web.xml in the examples webapp.
>
> If I do use commons-logging+log4j and want to write my own logs to that
same
> tomcat logs directory, what's the best [cross-platform] way to specify the
> location?  I'm currently using:
>    log4j.appender.rolling.File=../../../logs/myWebApp.log
> which backs up out of WEB-INF/classes and moves down into the logs
> directory.
>
> I'm very new at this, so please tell me if I'm going about it all wrong!
>
> --
> Wendy Smoak
> Applications Systems Analyst, Sr.
> Arizona State University PA Information Resources Management
>

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


Re: Tomcat + commons-logging + log4j

Posted by Jacob Kjome <ho...@visi.com>.
Hello Wendy,

Set up your <Context ...> entry to look something like this:

<Context path="/myapp" docBase="myapp" debug="5">
    <Logger 
        className="org.apache.catalina.logger.FileLogger"
        prefix="localhost_myapp_servlet_log."
        suffix=".txt"
            timestamp="true" />
</Context>

Setting the debug flag to higher numbers will give you more and more
output...to a point. I just use "5" and it seems to give me all the
info I need.  Either read the docs to find out more specifics about it
or just experiment.

Now, this won't log info for you classes specifically.  It will log
stuff based on what the Tomcat server classes want to log.  If you
want to log on your own, I wouldn't bother with commons-logging.  Use
Log4j directly.  See here for reasons:
http://qos.ch/logging/thinkAgain.html

Jake

Monday, December 09, 2002, 1:45:17 PM, you wrote:


WS> I need help with logging.  I have just today convinced commons-logging and
WS> log4j to work together, and now I would like to do logging from my webapp.

WS> My first question is whether I really need commons-logging and log4j at all.
WS> I see that tomcat is already producing some logs in /path/to/tomcat/logs.
WS> However, I can't figure out how to get one of those for my own webapp.  I
WS> only see logs for admin, examples, and a generic log.  I have read 'The
WS> Logger Component' in the docs, but it doesn't have any info on
WS> configuration.  I don't see any references to logging in server.xml or the
WS> global web.xml or the web.xml in the examples webapp.

WS> If I do use commons-logging+log4j and want to write my own logs to that same
WS> tomcat logs directory, what's the best [cross-platform] way to specify the
WS> location?  I'm currently using:
WS>    log4j.appender.rolling.File=../../../logs/myWebApp.log
WS> which backs up out of WEB-INF/classes and moves down into the logs
WS> directory.

WS> I'm very new at this, so please tell me if I'm going about it all wrong!




-- 
Best regards,
 Jacob                            mailto:hoju@visi.com


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