You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Marco Perrando <pe...@com.dist.unige.it> on 2002/02/20 16:44:12 UTC

Use of PropertyConfigurator

I need to initialize my log4j system by PropertyConfigurator. I need a RollingFileAppender, but I know the file name only at runtime (actually it's read from a ServletContext - InitParameter value).

So I call PropertyConfigurator.configure.... and after I set the file manually with

((RollingFileAppender)Category.getRoot().getAppender("<theAppenderName>")).setFile("<theFileName>",true);

Everything goes ok, but I get the annoying WARN message out to the console

log4j:WARN File option not set for appender [<theAppenderName>].
log4j:WARN Are you using FileAppender instead of ConsoleAppender?

Everytime the servlet initializes the log4j system.

Is there any chance to avoid this annoying message?
Or even better.
Is there another way to initialize the RollingFileAppender directly into the properties file, by accessing the InitParameter of my servlet context (IMO it's impossible...)

Thank you!

Re: Use of PropertyConfigurator

Posted by T Master <tm...@iknowledge.com>.
You misunderstood.

If you change the filename dynamically at runtime, then activate it by calling
    appender.activateOptions();

if you use a config file, then you do NOT need to call
appender.activateOptions()  (until later if u change the filename at runtime).
In the config file... you be specifying the file option.
With the properties file:
    log4j.appender.MYAPPENDER.File = c:\\log.txt

Research the XML format for yourself.

HTH

T Master

----- Original Message -----
From: "Marco Perrando" <pe...@com.dist.unige.it>
To: "Log4J Users List" <lo...@jakarta.apache.org>
Sent: Wednesday, February 20, 2002 9:08 AM
Subject: Re: Use of PropertyConfigurator


> Where must I call it? Is this ironic? :)
> If I call it in my code I get those annoying messages two times!! :)))
>
> There should be a way to avoid the PropertyConfigurator to call
> activateOptions() for a particular Appender, so that it can be called inside
> the code. That should work. But is there an option for the property file
> that tells to the Configurator to NOT call activateOptions for an Appender?
>
> ----- Original Message -----
> From: "T Master" <tm...@iknowledge.com>
> To: "Log4J Users List" <lo...@jakarta.apache.org>
> Sent: Wednesday, February 20, 2002 4:46 PM
> Subject: Re: Use of PropertyConfigurator
>
>
> > Call :
> >
> > appender.activateOptions();
> >
> > :)
> >



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


Re: Use of PropertyConfigurator

Posted by Marco Perrando <pe...@com.dist.unige.it>.
Where must I call it? Is this ironic? :)
If I call it in my code I get those annoying messages two times!! :)))

There should be a way to avoid the PropertyConfigurator to call
activateOptions() for a particular Appender, so that it can be called inside
the code. That should work. But is there an option for the property file
that tells to the Configurator to NOT call activateOptions for an Appender?

----- Original Message -----
From: "T Master" <tm...@iknowledge.com>
To: "Log4J Users List" <lo...@jakarta.apache.org>
Sent: Wednesday, February 20, 2002 4:46 PM
Subject: Re: Use of PropertyConfigurator


> Call :
>
> appender.activateOptions();
>
> :)
>
>
> ----- Original Message -----
> From: "Marco Perrando" <pe...@com.dist.unige.it>
> To: <lo...@jakarta.apache.org>
> Sent: Wednesday, February 20, 2002 8:44 AM
> Subject: Use of PropertyConfigurator
>
>
> I need to initialize my log4j system by PropertyConfigurator. I need a
> RollingFileAppender, but I know the file name only at runtime (actually
it's
> read from a ServletContext - InitParameter value).
>
> So I call PropertyConfigurator.configure.... and after I set the file
manually
> with
>
>
((RollingFileAppender)Category.getRoot().getAppender("<theAppenderName>")).s
etFi
> le("<theFileName>",true);
>
> Everything goes ok, but I get the annoying WARN message out to the console
>
> log4j:WARN File option not set for appender [<theAppenderName>].
> log4j:WARN Are you using FileAppender instead of ConsoleAppender?
>
> Everytime the servlet initializes the log4j system.
>
> Is there any chance to avoid this annoying message?
> Or even better.
> Is there another way to initialize the RollingFileAppender directly into
the
> properties file, by accessing the InitParameter of my servlet context (IMO
it's
> impossible...)
>
> Thank you!
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


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


Re: Use of PropertyConfigurator

Posted by T Master <tm...@iknowledge.com>.
Call :

appender.activateOptions();

:)


----- Original Message -----
From: "Marco Perrando" <pe...@com.dist.unige.it>
To: <lo...@jakarta.apache.org>
Sent: Wednesday, February 20, 2002 8:44 AM
Subject: Use of PropertyConfigurator


I need to initialize my log4j system by PropertyConfigurator. I need a
RollingFileAppender, but I know the file name only at runtime (actually it's
read from a ServletContext - InitParameter value).

So I call PropertyConfigurator.configure.... and after I set the file manually
with

((RollingFileAppender)Category.getRoot().getAppender("<theAppenderName>")).setFi
le("<theFileName>",true);

Everything goes ok, but I get the annoying WARN message out to the console

log4j:WARN File option not set for appender [<theAppenderName>].
log4j:WARN Are you using FileAppender instead of ConsoleAppender?

Everytime the servlet initializes the log4j system.

Is there any chance to avoid this annoying message?
Or even better.
Is there another way to initialize the RollingFileAppender directly into the
properties file, by accessing the InitParameter of my servlet context (IMO it's
impossible...)

Thank you!



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