common variable for log4j.xml configuration

BloodShedd

New Member
I have log4j.xml configuration like this:\[code\]<appender name="MyAppender"class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="http://stackoverflow.com/logs/custom/my.log"/>... </appender>\[/code\]However the root directory of my file are the same for a lot of appender. Is there a way to defined "/logs/custom/" as a variable and reused it in all of my appender.Thanks,Sean
 

Mohan Rathour

New Member
BloodShedd said:
I have log4j.xml configuration like this:\[code\]<appender name="MyAppender"class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="http://stackoverflow.com/logs/custom/my.log"/>... </appender>\[/code\]However the root directory of my file are the same for a lot of appender. Is there a way to defined "/logs/custom/" as a variable and reused it in all of my appender.Thanks,Sean
[/quote


It is possible in XML as well to define a variable and reuse it in the rest of the doc:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" [
<!ENTITY logHome "/logs/folder1/folder2">
]
>

Then, refer to this variable just defined, as &logHome;

<param name="File" value="&logHome;/folder3/my.log"/>
 
Top