Relative paths are used in the log4j.properties file.
How can i find the absolute path programatically where logs are stored?
Relative paths are used in the log4j.properties file.
How can i find the absolute path programatically where logs are stored?
I think one way is like this:
since the path is relative to system property "user.dir"
so relative path =
./app.log
becomes{user.dir}/app.log
From: http://www.gunith.com/2010/11/how-to-get-the-file-path-of-a-log4j-log-file/
Assume the log4j.properties file is as below,
In such case, your Java code should be as follows,
Note that migrationlog was used to create the logger object in the first line. And migration is used to get the FileAppender which in turn calls getFile() to get the log File object.