The use case is that each log message has a common set of attributes. Useful are:
- "environment" with values like prod/live, test, uat, integration, staging3
- "application" to use a single ELK installation for the whole IT department
- "service" to split a single application. Values are "user", "shipping", ...
Application and service are usually fixed for a certain war-file while the environment depends on the deployment.
In the logback case a single config file is created during the building/deployment process which ensures that each log message has all these attributes. The question is how this could be achieved with log4j.
One solution we discussed internally was to put these attributes in all MDCs. But it hard to ensure that each Thread is covered. So I could also image a solution which doesn't add this feature to a or multiple Layouts but which changes the way the LoggingEvent is created. So that you can specify a fixed base set of properties each LoggingEvent will have.