logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject RE: Creating log files relative to the web applications root directory?
Date Wed, 13 Aug 2003 19:46:26 GMT

Well, actually, under Tomcat, I wrote an InitContextListener which 
automagically figures out where the current webapp exists and sets a system 
property which is referenced in log4j.xml and,  viola!, the log files are 
placed in WEB-INF/logs of the current application no matter where it exists 
and without ever hardcoding the actual path.  Of course, this assumes you 
actually have write access to your webapp which is not guaranteed by the 
servlet spec.  In that case, your file appender will not work since it 
won't have a valid location to write to.

See the InitContextListener in the log4j-sandbox.  Instructions are in the 
javadoc.  See info and links here...
http://nagoya.apache.org/wiki/apachewiki.cgi?Log4JProjectPages/AppContainerLogging

Jake

At 08:35 PM 8/13/2003 +1000, you wrote:
>G'day,
>
>Ummmm, so basically then it is not possible to define a directory path in
>the log4j.xml properties file so that log files are placed relative to the
>web apps root directory?  Or for that matter relative to any known anchor
>point like the server root directory?
>
>A problem we have is that we deploy .war files by sending the package to the
>server gods who then drop it into the webapps directory.  Alas we don't have
>the rights to deploy directly to the server environment and tools like ANT
>whilst are good at building a distributable archive they do not quite make
>the grade when resolving tokens in a dynamic style of deployment.  Another
>issue we have is that most of the development work is done on a Windows
>based machine and the production servers are hosted on a flavor of Unix.
>Hard coding a directory path like "C:\..\" may work when doing the dev work
>under Windows but just don't kind of cut it on a Unix file system when it
>comes time to deployment.
>
>BTW, the last time I looked me was male so I'll opt out for king!
>
>AB
>
>-----Original Message-----
>From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com]
>Sent: Monday, 11 August 2003 11:14 PM
>To: Log4J Users List
>Subject: RE: Creating log files relative to the web applications root
>directory?
>
>
>
>Howdy,
>I suppose Adrian could be a woman's name as well, so you're right ;)
>
><AmendedVersion>
>But if you're the server admin, you're king (or queen) ;) </AmendedVersion>
>
>Yoav Shapira
>Millennium ChemInformatics
>
>
> >-----Original Message-----
> >From: Caroline Wood [mailto:Caroline.Wood@cpp.co.uk]
> >Sent: Monday, August 11, 2003 9:13 AM
> >To: 'Log4J Users List'
> >Subject: RE: Creating log files relative to the web applications root
> >directory?
> >
> >or Queen! lol ;)
> >
> >-----Original Message-----
> >From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com]
> >Sent: 11 August 2003 14:05
> >To: Log4J Users List; a.beech@bigpond.net.au
> >Subject: RE: Creating log files relative to the web applications root
> >directory?
> >
> >
> >
> >Howdy,
> >What I've seen done to achieve this is have my ant deployment script
> >fill the value when copying log4j.xml over.  So in log4j.xml, you'd
>have
> >
> ><param name="File" value="@logFilePath@" />
> >
> >And in your ant script, you set filtering="true" when copying
>log4j.xml,
> >and replac the logFilePath token with the actual (absolute) path.
> >
> >As an aside, note that the servlet container is not required to give
>you
> >write access under your webapp's root.  In fact, many server admins
> >dislike this, as they prefer a centralized log location for their
> >systems.  But if you're the server admin, you're king ;)
> >
> >Yoav Shapira
> >Millennium ChemInformatics
> >
> >
> >>-----Original Message-----
> >>From: Adrian Beech [mailto:a.beech@bigpond.net.au]
> >>Sent: Monday, August 11, 2003 6:42 AM
> >>To: 'Log4J Users List'
> >>Subject: Creating log files relative to the web applications root
> >>directory?
> >>
> >>G'day,
> >>
> >>Is it possible to specify a log filename in the XML log4j properties
> >file
> >>so
> >>that it is relative to the web applications root directory?
> >>
> >>I have the following in a log4j.xml file located in web-inf/classes
> >with
> >>the
> >>log4j jar in the web-inf/lib directory.  Logging seems to be fine
> >except
> >>the
> >>"rascal.log" file is being created in the Tomcat application directory
> >>under C:\Program Files\ and not in the C:\Tomcat 4.1\webapps\...
> >>Directory
> >tree.
> >>I'd prefer to have the log files in something like
> >>../webapps/<application>/logs/<logfilename>.  Is this possible?
> >>
> >>BTW, took a while to find the rascal.log file!!!
> >>
> >>--[log4j.xml]---------------------------------------------------------
> >>?xml version="1.0" encoding="UTF-8" ?>
> >><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> >>
> >><log4j:configuration>
> >>
> >>    <appender name="rf" class="org.apache.log4j.RollingFileAppender">
> >>        <param name="file" value="rascal.log"/>
> >>        <param name="maxBackupIndex" value="2"/>
> >>        <param name="maxFileSize" value="250KB"/>
> >>
> >>        <layout class="org.apache.log4j.PatternLayout">
> >>            <param name="ConversionPattern" value="%d{dd/MM/yyyy
> >HH:mm:ss}
> >>%-5p (%t) %l - %m%n"/>
> >>        </layout>
> >>    </appender>
> >>
> >>    <root>
> >>        <priority value="debug" />
> >>        <appender-ref ref="rf"/>
> >>    </root>
> >>
> >></log4j:configuration>
> >>--[End Of File]-------------------------------------------------------
> >>
> >>I'm using Tomcat 4.1.24 on a Win XP and 2k box for development and
> >Tomcat
> >>4.1.24 on a Unix box as the production platform.
> >>
> >>AB
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> >
> >
> >
> >
> >This e-mail, including any attachments, is a confidential business
> >communication, and may contain information that is confidential,
> >proprietary and/or privileged.  This e-mail is intended only for the
> >individual(s)
>to
> >whom it is addressed, and may not be saved, copied, printed, disclosed
>or
> >used by anyone else.  If you are not the(an) intended recipient, please
> >immediately delete this e-mail from your computer system and notify the
> >sender.  Thank you.
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> >
> >
> >_______________________________________________________________________
>_
> >This email has been scanned for all viruses by the MessageLabs Email
> >Security System. For more information on a proactive email security
> >service working around the clock, around the globe, visit
> >http://www.messagelabs.com
> >_______________________________________________________________________
>_
> >
> >This is an email from The CPP Group, Holgate Park, York, YO26 4GA;
> >telephone 01904 544500. This message may contain information that is
> >confidential. If you are not the intended recipient, you may not
>peruse,
> >use, disseminate, distribute or copy this message. If you have received
> >this message in error, please notify the sender immediately by email,
> >facsimile or telephone and either return or destroy the original
>message.
> >The CPP Group accept no responsibility for any changes made to this
>message
> >after it has been sent by the original author.
> >
> >
> >_______________________________________________________________________
>_
> >This email has been scanned for all viruses by the MessageLabs Email
> >Security System. For more information on a proactive email security
> >service working around the clock, around the globe, visit
> >http://www.messagelabs.com
> >_______________________________________________________________________
>_
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
>
>
>
>This e-mail, including any attachments, is a confidential business
>communication, and may contain information that is confidential, proprietary
>and/or privileged.  This e-mail is intended only for the individual(s) to
>whom it is addressed, and may not be saved, copied, printed, disclosed or
>used by anyone else.  If you are not the(an) intended recipient, please
>immediately delete this e-mail from your computer system and notify the
>sender.  Thank you.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org


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


Mime
View raw message