Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a single logback.xml file for multiple applications a good practice?

There are multiple applications deployed on my Tomcat server.

At first everyone had it's one logback.xml file packaged in WEB-INF/classes with it.

Then I've put another directory outside the Tomcat's deploy directory on the common classpath, put a single logback.xml there and excluded the other ones from the applications. The reason for that was that I wanted logging to be conveniently configurable in one place.

Unfortunately there's the requirement now to log every application to it's own file.

Since I think that this is not so easy to achieve with this setup, I'm wondering whether this setup is that good at all. What do you think?

like image 775
Harold L. Brown Avatar asked Dec 18 '13 11:12

Harold L. Brown


3 Answers

Unfortunately there's the requirement now to log every application to it's own file.

I think, that this is the only correct way to do it. It is ok to have several log files for single application, but to have many applications writing in the same log is bad practice.

like image 155
arghtype Avatar answered Sep 28 '22 17:09

arghtype


What you want to do to have a single configuration file is to use a SiftAppender.

like image 28
foch Avatar answered Sep 28 '22 18:09

foch


LOGS need to be easy to read and easy to parse by any user. If you have a single log file where multiple applications writing to the same file you might jumble up the various log entries. Since you are the developer who has knowledge of all 7 applications you might be able to get it but a new developer will have a difficult time understanding the logs. Logs should be concise and easy to decipher so that support issues can be analysed just be analyzing the log entries.

I would suggest you follow these tips

like image 41
Pratik Shelar Avatar answered Sep 28 '22 19:09

Pratik Shelar