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 jgarrison <jg...@troux.com> on 2009/08/19 23:22:05 UTC

log4j.properties and substition of user properties

I have the following in a log4j.properties

...
log4j.appender.LogFile=org.apache.log4j.FileAppender
log4j.appender.LogFile.layout=org.apache.log4j.PatternLayout
log4j.appender.LogFile.layout.ConversionPattern=[%6r] %8c{1} : %m%n
log4j.appender.LogFile.file=${work.dir}/build.log
log4j.appender.LogFile.append=false
...

This is being used by an invocation of ANT in which the command line
contains 

    ....  -Dwork.dir=/a/valid/directory .....

The ANT property ${work.dir} is successfully referenced in the ANT
buildfiles, but log4j resolves it to the null string, attempting to put the
build.log file in the root, which obviously doesn't work.  I know ANT is
using the log4j.properties because when I put in an absolute path for
LogFile.file it works correctly.

Based on my reading of the docs, I expected this to work, and the fact that
${work.dir} gets replaced with a null string tells me that log4j is
attempting to resolve it, but just doesn't have a value for it.  What do I
need to do to get the value to log4j?

If this question is more appropriate for an ANT forum I apologize in
advance.
-- 
View this message in context: http://www.nabble.com/log4j.properties-and-substition-of-user-properties-tp25052177p25052177.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


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


Re: log4j.properties and substition of user properties

Posted by Jacob Kjome <ho...@visi.com>.
Are you sure this isn't caused by a forked VM, such as via the <ant/> task for
<junit fork="true"/>?  In those cases, the -D command line param won't be passed
to the forked VM.  You'd have to provide those as params to the tasks invoking the
forked VM.

Jake

On 8/19/2009 3:22 PM, jgarrison wrote:
> I have the following in a log4j.properties
> 
> ...
> log4j.appender.LogFile=org.apache.log4j.FileAppender
> log4j.appender.LogFile.layout=org.apache.log4j.PatternLayout
> log4j.appender.LogFile.layout.ConversionPattern=[%6r] %8c{1} : %m%n
> log4j.appender.LogFile.file=${work.dir}/build.log
> log4j.appender.LogFile.append=false
> ...
> 
> This is being used by an invocation of ANT in which the command line
> contains 
> 
>     ....  -Dwork.dir=/a/valid/directory .....
> 
> The ANT property ${work.dir} is successfully referenced in the ANT
> buildfiles, but log4j resolves it to the null string, attempting to put the
> build.log file in the root, which obviously doesn't work.  I know ANT is
> using the log4j.properties because when I put in an absolute path for
> LogFile.file it works correctly.
> 
> Based on my reading of the docs, I expected this to work, and the fact that
> ${work.dir} gets replaced with a null string tells me that log4j is
> attempting to resolve it, but just doesn't have a value for it.  What do I
> need to do to get the value to log4j?
> 
> If this question is more appropriate for an ANT forum I apologize in
> advance.

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