Great idea, Paul. Following your idea, I also had to take the
following steps (posted here to leave an answer in the archives):
- use ${log4j.user.home} in my log4j.properties
- in my main() method, *very first* I obtain
System.getProperty("user.home") and .replace('\\', '/') in it, sending
the result to System.setProperty("log4j.user.home", ...)
- In my main-class, change the Logger definition from static final to
simply an object property. For me, I was able to do this without much
recourse because my main-class is effectively a singleton anyway. I
had to prevent log4j from initializing at class load of
MyMainClass.class (from the Logger declaration).
Thanks again,
-Scott Heaberlin
On Thu, Aug 14, 2008 at 11:39 PM, Paul Smith <[EMAIL PROTECTED]> wrote:
>>
>> 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.
>>
>
> Tricky. One other suggestion is to at startup create a new System Property
> variable (before log4j starts, say 'log4config.user.home') that is based on
> the value of ${user.home} and do the 'unescaping' by changing '\'->'/' (if
> on Windows?). Java has now long supported '/' as a valid path on all
> platforms, so "C:/Documents and Settings/username" works fine.
>
> cheers,
>
> Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]