tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kunal Shah" <kunals...@users.sourceforge.net>
Subject RE: Help with log4j and log4j.propereties under Tomcat 4.1.2
Date Sat, 26 Oct 2002 12:11:38 GMT
I am using something like this in my servlet

public void init(ServletConfig config) throws
ServletException {
        super.init(config);

        //read the config file here.

        try {

            String lc_str_propPath =
getServletContext().getRealPath("/") +
"/WEB-INF/log4j.properties";
            PropertyConfigurator.configure(lc_str_propPath);

            log.debug("Entering into init method");

		.........


You can change the string "/WEB-INF/log4j.properties"


--kunal


> -----Original Message-----
> From: Andreas Probst [mailto:andpro77@gmx.net]
> Sent: Thursday, October 24, 2002 11:48 AM
> To: Tomcat Users List
> Subject: Re: Help with log4j and
> log4j.propereties under Tomcat 4.1.2
>
>
> Hi CC,
>
> I also wanted to have them in WEB-INF. The
> following code works
> for me (TC 4.0.4). You can even rename the
> log4j.properties to
> whatever you want. This solution is supposed to
> work in not
> expanded wars, too.
>
>     InputStream log4jPropsIn =
> getServletContext().getResourceAsStream("WEB-INF/l
> og4j.properties");
>     if (log4jPropsIn == null)
>     {
>       // Set up a simple configuration that logs
> on the console.
>       BasicConfigurator.configure();
>     }
>     else
>     {
>       Properties logProps = new Properties();
>       try
>       {
>         logProps.load(log4jPropsIn);
>         // BasicConfigurator replaced with
> PropertyConfigurator.
>         PropertyConfigurator.configure(logProps);
>       }
>       catch (IOException io)
>       {
>         // Set up a simple configuration that
> logs on the console.
>         BasicConfigurator.configure();
>       }
>     }//else
>       logger.info("log4j configuration finished");
>
> Good luck.
>
> Andreas
>
> On 23 Oct 2002 at 10:29, Carson, Chuck wrote:
>
> >
> > I am using log4j and have the log4j.jar file located in
> > $TOMCAT_HOME/webapps/<myapp>/WEB-INF/classes.
> For some reason, I can
> > only place the log4j.properties file in the
> same directory as the jar
> > file. Is this proper behavior? I would like to
> keep the log4j.properties
> > file in WEB-INF/.
> >
> > Thanks for any help
> > CC
> >
> >
> > ----------
> > This message contains confidential information
> and is intended only for
> > the individual named. If you are not the named
> addressee you should not
> > disseminate, distribute or copy this e-mail.
> Please notify the sender
> > immediately by e-mail if you have received this
> e-mail by mistake and
> > delete this e-mail from your system. E-mail
> transmission cannot be
> > guaranteed to be secure or error-free as
> information could be
> > intercepted, corrupted, lost, destroyed, arrive
> late or incomplete, or
> > contain viruses. The sender therefore does not
> accept liability for any
> > errors or omissions in the contents of this
> message, which arise as a
> > result of e-mail transmission. If verification
> is required please
> > request a hard-copy version.
> >
>
>


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message