Harold L. Brown
Harold L. Brown

Reputation: 9966

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?

Upvotes: 8

Views: 3229

Answers (3)

foch
foch

Reputation: 1059

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

Upvotes: 2

arghtype
arghtype

Reputation: 4534

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.

Upvotes: 2

Pratik Shelar
Pratik Shelar

Reputation: 3212

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

Upvotes: 1

Related Questions