views:

23

answers:

1

Hi all, in windows, when I use the following File path, log4j will write the file to C:\eclipse\logs\appLog.log (I am using eclipse as the IDE in windows):

log4j.appender.R.File=logs/appLog.log

Then when I deploy the jsp to the apache tomcat in a Linux server, where does the log file go? (I try to avoid using absolute path because I will need to remember changing the path after deployed to linux) Thanks in advance.

A: 

Using relative local disk file system paths in an application is an extremely bad idea. They will be relative to the "current working directory", i.e. the directory which was currently opened when the application was started up. It can be everywhere and this is completely out of control from your application.

Always use absolute local disk file system paths starting with a leading /.

BalusC
Thanks Balus, but then I will have to remember changing the path when I deploy it to a linux server since I am developing in windows. Do you have a better way that I can avoid this error-prone manual work? For other paths, I am setting two different paths in a property file (one for windows and the other one for linux), then I check the OS to determine which property to be used. However, for log4j, I can not control this, can't I?
Kenneth
Just use the same path on both environments and document it properly in installation guide. E.g. `/var/webapp/logs` or so. In Windows, paths starting with `/` are completely valid as well. It will use the same disk as where the server is installed on.
BalusC
Cool!!.. I didn't know windows accept the '/' path notation.. Thanks a lot.
Kenneth
You're welcome.
BalusC