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 Wendy Smoak <We...@asu.edu> on 2004/01/05 19:30:03 UTC

Help with replacing tokens for log file name

I'm not sure whether this is more Ant or Log4j, so please send me along
if I'm not in the right place.

In build.xml, I have this:
   <target name="props-dev" depends="copy-props">
     <replace file="${propsdir}/log4j.properties" 
                token="@logFileName@" 
                value="${env.TOMCAT_HOME}\logs\${context}.log"/>
   </target>

It's turning this in log4j.properties:
   log4j.appender.daily.File=@logFileName@
into this:
 
log4j.appender.daily.File=c:\jakarta\jakarta-tomcat-4.1.29\logs\coldev.l
og

Unfortunately, this results in log messages going to a file called
   jakartajakarta-tomcat-4.1.29logscoldev.log
in the c:\jakarta\jakarta-tomcat-4.1.29\bin directory.

I tried quoting  @logFileName@ but that produced:
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException:
"c:jakartajakarta-tomcat-4.1.29logscoldev.log" (T
he filename, directory name, or volume label syntax is incorrect)
when the webapp is started.

I think the answer is to escape the backslashes, but since part of it
comes from a system property, I don't see how.

Is there a way to do this on Windows?  I can just use a .properties file
for the token/value replacements, I was trying to avoid hard-coding as
much as possible though.

-- 
Wendy Smoak
Application Systems Analyst, Sr.
ASU IA Information Resources Management 


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