Michael
Michael

Reputation: 42050

Logging in web application deployed as WAR

I am coding a Java web web application packaged as war and I would like to add logging and specify the log folder to write log files to (using configuration file, e.g. logback.xml)

Obviously, I would not like to configure the absolute path of the folder. Now I wonder how to configure the log folder in war. What are the best practices and recommended approaches to this?

Upvotes: 0

Views: 112

Answers (1)

km1
km1

Reputation: 2443

We use to use relative paths in logback.xml but changed to using an env property. When the path was relative we could never tell the customer exactly where the log file was due to different Java EE server implementations. Using an absolute path with an env variable made it easier. For example

<file>${user.dir}/logs/my_web_app.log</file>

Upvotes: 3

Related Questions