Tutorial :In Linux, where is the default root directory for log4j.appender.R.File?



Question:

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.


Solution:1

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 /.


Solution:2

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


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »