Hello Log4jers,

I've been a user of log4j for nearly 8 years now.  Tried other
frameworks; still using good ole' log4j.

I did a brief archive search for this question and found no similar
ones so forgive me if this has been asked before but I did at least
attempt to look.

I think I am having some trouble with PropertyConfigurator's variable expansion:

My log4j.properties file snippet:

log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.FILE.File=${user.home}/MyLogFile.log
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=### %d [%-5p] [%c] %x - %m%n

What I'm seeing is that on Windows, ${user.home} is of course
resolving to C:\Documents and Settings\username.  However,
PropertyConfigurator seems to be expanding escape chars in this value.
 So on Windows, I never get the above log file because the path is
munged:  "C:Documents and Settings\username". The leading slash is
missing (as seen when I turn on -Dlog4j.debug and see LogLog output).

Worse, if a person's username starts with something, say an "n" or
"t", you get  "C:Documents and Settings     heusername"  (in this
case, user "theusername" turned into \t).  I have code elsewhere in
the app that reads the user.home system property with no problems.

I'm deploying this app via WebStart so I don't have much control over
the user running the JRE.

The only workaround I can think of is to subclass FileAppender, give
it a setter method called setSystemPropertyDirPrefix, then in
log4j.properties refrain from File=${user.home}.  Instead, I'd use
SystemPropertyDirPrefix=user.home (no variable) and within the coded
FileAppender subclass do the System.getProperty() lookup.

Of course, I welcome any thoughts you all might have.

Regards,

Scott Heaberlin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to