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 Jay Riddell <jr...@doradosoftware.com> on 2001/08/08 04:13:44 UTC

Overriding an Xml Configuration's settings

I'm using XML files to configure Log4j.  All is working fine.

I've got a couple of custom priorities, some filters using the
FileAppender.  Life was good.

Then I discovered that I've got 1 log4j .xml file for EACH of
my different executables . . . and the only difference is the
filename.

Therefore, I tried using a single .xml config file and added
something that looks like this (once all the error handling is removed):

            Category theRoot = Category.getRoot() ;
            Appender theApp = theRoot.getAppender( "MyAppender" ) ;
            FileAppender fileApp = (FileAppender) theApp ;
            fileApp.setFile( thisExecutablesFileName ) ;

But it doesn't work.  If I have a filename set in the xml file, it uses that.
If I don't, I get the following:

    log4j:WARN File option not set for appender [MyAppender].
    log4j:WARN Are you using FileAppender instead of ConsoleAppender?
    log4j: Adding appender named [MyAppender] to category [root].
    log4j:ERROR No output stream or file set for the appender named [MyAppender].


Any ideas how I can use the same .XML file for each of my executables
while still configuring each to write to a different output file ?

TIA.

----------------------------------------------------------------
Jay Riddell
Dorado Software


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


Re: Overriding an Xml Configuration's settings

Posted by Ceki Gülcü <cg...@qos.ch>.
Hi,

Please see the documentation on PropertyConfigurator. 

At 08:44 08.08.2001 -0700, Jay Riddell wrote:

>Ummmm, ok . . .thanks.  But what do you mean by that ?
>
>I believe that I am trying to set the "variable" called fileName
>in the FileAppender class (but it is not working).
>
>Can anyone be a bit more specific than this ?
>
>
>----- Original Message -----
>From: "Ceki Gülcü" <cg...@qos.ch>
>To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
>Sent: Tuesday, August 07, 2001 10:41 PM
>Subject: Re: Overriding an Xml Configuration's settings
>
>
>
>Jay,
>
>You can use variable substitution. Regards, Ceki
>
>At 19:13 07.08.2001 -0700, Jay Riddell wrote:
>>I'm using XML files to configure Log4j.  All is working fine.
>>
>>I've got a couple of custom priorities, some filters using the
>>FileAppender.  Life was good.
>>
>>Then I discovered that I've got 1 log4j .xml file for EACH of
>>my different executables . . . and the only difference is the
>>filename.
>>
>>Therefore, I tried using a single .xml config file and added
>>something that looks like this (once all the error handling is removed):
>>
>>            Category theRoot = Category.getRoot() ;
>>            Appender theApp = theRoot.getAppender( "MyAppender" ) ;
>>            FileAppender fileApp = (FileAppender) theApp ;
>>            fileApp.setFile( thisExecutablesFileName ) ;
>>
>>But it doesn't work.  If I have a filename set in the xml file, it uses that.
>>If I don't, I get the following:
>>
>>    log4j:WARN File option not set for appender [MyAppender].
>>    log4j:WARN Are you using FileAppender instead of ConsoleAppender?
>>    log4j: Adding appender named [MyAppender] to category [root].
>>    log4j:ERROR No output stream or file set for the appender named [MyAppender].
>>
>>
>>Any ideas how I can use the same .XML file for each of my executables
>>while still configuring each to write to a different output file ?
>>
>>TIA.
>>
>>----------------------------------------------------------------
>>Jay Riddell
>>Dorado Software
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
>--
>Ceki Gülcü - http://qos.ch
>
>
>---------------------------------------------------------------------
>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

--
Ceki Gülcü - http://qos.ch


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


Re: Overriding an Xml Configuration's settings

Posted by Jay Riddell <jr...@doradosoftware.com>.
Ummmm, ok . . .thanks.  But what do you mean by that ?

I believe that I am trying to set the "variable" called fileName
in the FileAppender class (but it is not working).

Can anyone be a bit more specific than this ?


----- Original Message -----
From: "Ceki Gülcü" <cg...@qos.ch>
To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
Sent: Tuesday, August 07, 2001 10:41 PM
Subject: Re: Overriding an Xml Configuration's settings



Jay,

You can use variable substitution. Regards, Ceki

At 19:13 07.08.2001 -0700, Jay Riddell wrote:
>I'm using XML files to configure Log4j.  All is working fine.
>
>I've got a couple of custom priorities, some filters using the
>FileAppender.  Life was good.
>
>Then I discovered that I've got 1 log4j .xml file for EACH of
>my different executables . . . and the only difference is the
>filename.
>
>Therefore, I tried using a single .xml config file and added
>something that looks like this (once all the error handling is removed):
>
>            Category theRoot = Category.getRoot() ;
>            Appender theApp = theRoot.getAppender( "MyAppender" ) ;
>            FileAppender fileApp = (FileAppender) theApp ;
>            fileApp.setFile( thisExecutablesFileName ) ;
>
>But it doesn't work.  If I have a filename set in the xml file, it uses that.
>If I don't, I get the following:
>
>    log4j:WARN File option not set for appender [MyAppender].
>    log4j:WARN Are you using FileAppender instead of ConsoleAppender?
>    log4j: Adding appender named [MyAppender] to category [root].
>    log4j:ERROR No output stream or file set for the appender named [MyAppender].
>
>
>Any ideas how I can use the same .XML file for each of my executables
>while still configuring each to write to a different output file ?
>
>TIA.
>
>----------------------------------------------------------------
>Jay Riddell
>Dorado Software
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

--
Ceki Gülcü - http://qos.ch


---------------------------------------------------------------------
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


Re: Overriding an Xml Configuration's settings

Posted by Ceki Gülcü <cg...@qos.ch>.
Jay,

You can use variable substitution. Regards, Ceki

At 19:13 07.08.2001 -0700, Jay Riddell wrote:
>I'm using XML files to configure Log4j.  All is working fine.
>
>I've got a couple of custom priorities, some filters using the
>FileAppender.  Life was good.
>
>Then I discovered that I've got 1 log4j .xml file for EACH of
>my different executables . . . and the only difference is the
>filename.
>
>Therefore, I tried using a single .xml config file and added
>something that looks like this (once all the error handling is removed):
>
>            Category theRoot = Category.getRoot() ;
>            Appender theApp = theRoot.getAppender( "MyAppender" ) ;
>            FileAppender fileApp = (FileAppender) theApp ;
>            fileApp.setFile( thisExecutablesFileName ) ;
>
>But it doesn't work.  If I have a filename set in the xml file, it uses that.
>If I don't, I get the following:
>
>    log4j:WARN File option not set for appender [MyAppender].
>    log4j:WARN Are you using FileAppender instead of ConsoleAppender?
>    log4j: Adding appender named [MyAppender] to category [root].
>    log4j:ERROR No output stream or file set for the appender named [MyAppender].
>
>
>Any ideas how I can use the same .XML file for each of my executables
>while still configuring each to write to a different output file ?
>
>TIA.
>
>----------------------------------------------------------------
>Jay Riddell
>Dorado Software
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

--
Ceki Gülcü - http://qos.ch


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