tags:

views:

20

answers:

1

I have a java application running on windows machines.

Long story short, we have a convention for where we place log files per machine:

\\%COMPUTERNAME%\Logs\<AppNameHere>

So I configured my Java app to startup with -Dmachine.name="%COMPUTERNAME%", and then in my log4j.properties file I specify

log4j.appender.R.File = \\${machine.name}\Logs\MyVerySpecialApplicationName\log.log

But I'm not seeing that directory / file show up when I run my application (the first thing the app does is log a startup message).

So my guess is that log4j / java can't process that windows specific UNC path.

Anyone else run into this issue and figure out a way around it?

+1  A: 

I looked at Log4j's source code. It appears to use java.io.File to hold a reference to the filename you specify.

Also, the Javadocs for java.io.File state that UNC paths are supported for the constructor of File (which Log4J uses).

So, on the surface, there's no reason why your configuration won't work; but - and that's the important point to note - Java has a long history of problems with file I/O over SMB (which is pretty much what you're trying to do).

My advice:

  1. Start your application by specifying -Dlog4j.debug=true. The system property will make Log4J spit lots of debug information to help you track the problem.
  2. Attempt using the same configuration, except that, instead of referring to the file with a UNC prefix, simply map the drives (I understand that you're running on Windows). If things work with mapped drives, it means that something in using the UNC prefix is the source of the problem (although I'd doubt it).

Let us know how things pan out. Good luck. Isaac

Isaac
Thanks, I'll try that momentarily!
ecoffey