You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by "stan.forums" <st...@gmail.com> on 2010/12/14 14:49:24 UTC

Local variable in XML configuration file

Hi all,

I wish to declare a local variable inside my xml configuration file, and
then later on i wish to access that variable. The reason being that i
declare many appenders in one config file. When i wish to change the path to
the log file in the appender, idon't want to have to edit each appender
separately, i would like to have a declared logpath variable at the top of
the config file and then just have to edit that one variable definition and
then all of the appenders will have the correct new path automagically.

thanks
-- 
View this message in context: http://old.nabble.com/Local-variable-in-XML-configuration-file-tp30454810p30454810.html
Sent from the Log4cxx - Users mailing list archive at Nabble.com.


Log4Cxx 0.9.7

Posted by Tan-Long Phan <lo...@cae.com>.
Hi

Just wonder if someone has successfully built this version of Log4Cxx on Linux? I tried to build but it requires libtool and then unable to compile libtool 2.4 on RedHawk 5.2.4 gcc 4.1.2

Thanks

Long



Re: Local variable in XML configuration file

Posted by "stan.forums" <st...@gmail.com>.
carnold-3,

Your advice was accurate, I guess that something else was causing the error. 

Thank you for your patience and help, xml is as familiar to me as ancient
Sanskrit



carnold-3 wrote:
> 
> 
> On Dec 16, 2010, at 4:44 AM, stan.forums wrote:
> 
>> 
>> Thanks for the prompt reply. This is what i did
>> 
>> <?xml version="1.0" encoding="UTF-8" ?>
>> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> 
>> <!DOCTYPE log4j:configuration [<!ENTITY logpath
>> "/home/stan/logfiles/presenceClient.txt">]> 
>> 
>>     <!-- Presence Appender-->
>>    <appender name="presenceClientFileAppender"
>> class="org.apache.log4j.RollingFileAppender">
>> 
>> 
>> 
>> 
>> 
>>       <layout class="org.apache.log4j.PatternLayout"> 
>> 
>>        </layout>
>>    </appender>
>> 
>> and this i the error i got
>> 
>> log4cxx: Error parsing file [/home/stan/datafiles/mugsim/LogConfig.xml],
>> Internal errorXML parser error code: not well-formed (invalid token) (4)
>> 
> 
> Any XML parser is required to reject that document.  The DOCTYPE block has
> to appear immediately after the <?xml>.
> 

-- 
View this message in context: http://old.nabble.com/Local-variable-in-XML-configuration-file-tp30454810p30497348.html
Sent from the Log4cxx - Users mailing list archive at Nabble.com.


Re: Local variable in XML configuration file

Posted by Curt Arnold <ca...@apache.org>.
On Dec 16, 2010, at 4:44 AM, stan.forums wrote:

> 
> Thanks for the prompt reply. This is what i did
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> 
> <!DOCTYPE log4j:configuration [<!ENTITY logpath
> "/home/stan/logfiles/presenceClient.txt">]> 
> 
>     <!-- Presence Appender-->
>    <appender name="presenceClientFileAppender"
> class="org.apache.log4j.RollingFileAppender">
> 
> 
> 
> 
> 
>       <layout class="org.apache.log4j.PatternLayout"> 
> 
>        </layout>
>    </appender>
> 
> and this i the error i got
> 
> log4cxx: Error parsing file [/home/stan/datafiles/mugsim/LogConfig.xml],
> Internal errorXML parser error code: not well-formed (invalid token) (4)
> 

Any XML parser is required to reject that document.  The DOCTYPE block has to appear immediately after the <?xml>.

Re: Local variable in XML configuration file

Posted by "stan.forums" <st...@gmail.com>.
Thanks for the prompt reply. This is what i did

<?xml version="1.0" encoding="UTF-8" ?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> 
<!DOCTYPE log4j:configuration [<!ENTITY logpath
"/home/stan/logfiles/presenceClient.txt">]> 

     <!-- Presence Appender-->
    <appender name="presenceClientFileAppender"
class="org.apache.log4j.RollingFileAppender">
        
       
        
        
        
       <layout class="org.apache.log4j.PatternLayout"> 
             
        </layout>
    </appender>

and this i the error i got

log4cxx: Error parsing file [/home/stan/datafiles/mugsim/LogConfig.xml],
Internal errorXML parser error code: not well-formed (invalid token) (4)



carnold-3 wrote:
> 
> You could use an XML internal entity for that:
> 
> <!DOCTYPE log4j:configuration [
> <!ENTITY myvariable 'somevalue''>
> ]>
> <log4j:configuration>
>     <logger name="&myvariable;">
>     </logger>
> </log4:configuration>
> 
> 
> See http://www.xml.com/pub/a/98/08/xmlqna2.html, the XML spec or any
> number of other resources.
> 
> On Dec 14, 2010, at 7:49 AM, stan.forums wrote:
> 
>> 
>> Hi all,
>> 
>> I wish to declare a local variable inside my xml configuration file, and
>> then later on i wish to access that variable. The reason being that i
>> declare many appenders in one config file. When i wish to change the path
>> to
>> the log file in the appender, idon't want to have to edit each appender
>> separately, i would like to have a declared logpath variable at the top
>> of
>> the config file and then just have to edit that one variable definition
>> and
>> then all of the appenders will have the correct new path automagically.
>> 
>> thanks
>> -- 
>> View this message in context:
>> http://old.nabble.com/Local-variable-in-XML-configuration-file-tp30454810p30454810.html
>> Sent from the Log4cxx - Users mailing list archive at Nabble.com.
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Local-variable-in-XML-configuration-file-tp30454810p30471541.html
Sent from the Log4cxx - Users mailing list archive at Nabble.com.


Re: Local variable in XML configuration file

Posted by Curt Arnold <ca...@apache.org>.
You could use an XML internal entity for that:

<!DOCTYPE log4j:configuration [
<!ENTITY myvariable 'somevalue''>
]>
<log4j:configuration>
    <logger name="&myvariable;">
    </logger>
</log4:configuration>


See http://www.xml.com/pub/a/98/08/xmlqna2.html, the XML spec or any number of other resources.

On Dec 14, 2010, at 7:49 AM, stan.forums wrote:

> 
> Hi all,
> 
> I wish to declare a local variable inside my xml configuration file, and
> then later on i wish to access that variable. The reason being that i
> declare many appenders in one config file. When i wish to change the path to
> the log file in the appender, idon't want to have to edit each appender
> separately, i would like to have a declared logpath variable at the top of
> the config file and then just have to edit that one variable definition and
> then all of the appenders will have the correct new path automagically.
> 
> thanks
> -- 
> View this message in context: http://old.nabble.com/Local-variable-in-XML-configuration-file-tp30454810p30454810.html
> Sent from the Log4cxx - Users mailing list archive at Nabble.com.
> 


Re: Local variable in XML configuration file

Posted by "stan.forums" <st...@gmail.com>.
OK,

I still get the same error, perhaps the error is in how i am using the
entity, though i have tried with/without quotes, brace bracets, etc. This is
what i have done:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration [<!ENTITY logpath
"/home/stan/logfiles/presenceClient.txt">]> 
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> 

    <appender name="presenceClientFileAppender"
class="org.apache.log4j.RollingFileAppender">
        
       
        
        
        
       <layout class="org.apache.log4j.PatternLayout"> 
             
        </layout>
    </appender>



stan.forums wrote:
> 
> Hi all,
> 
> I wish to declare a local variable inside my xml configuration file, and
> then later on i wish to access that variable. The reason being that i
> declare many appenders in one config file. When i wish to change the path
> to the log file in the appender, idon't want to have to edit each appender
> separately, i would like to have a declared logpath variable at the top of
> the config file and then just have to edit that one variable definition
> and then all of the appenders will have the correct new path
> automagically.
> 
> thanks
> 

-- 
View this message in context: http://old.nabble.com/Local-variable-in-XML-configuration-file-tp30454810p30496956.html
Sent from the Log4cxx - Users mailing list archive at Nabble.com.