In Linux, where is the default root directory for log4j.appender.R.File?
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 Linu开发者_运维技巧x 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.
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 /
.
Although an old question, I'm adding details so that future users can benefit.
Check my git project for an easy way to do it for multiple environments:
https://github.com/varunachar/Log4J-Multi-Environment
精彩评论