Tag Archives: Log4j

Log4j 2 configuration depending on environment

In a recent project, we used Log4j 2 as a backend for slf4j. Logging is configured differently for the local application start than for production. To do this, we used to have one configuration per environment and a piece of … Continue reading

Posted in Did you know? | Tagged , , , | 4 Comments

Using the context path of a web-app as log filename with Log4J

If you have a web application which you want to deploy more than once to a single servlet container you have the problem of separating your log files for the different web app instances. This is because the log configuration … Continue reading

Posted in Build, config and deploy | Tagged , , | 5 Comments

The condemned live longer

Years ago, Log4j 1.2 was released. Since then it was treated as dead by many developers. In the meantime logback appeared as successor of Log4j based on the slf4j API. But now, many years later, the development of log4j 2 is … Continue reading

Posted in Java Basics | Tagged , , , , | Leave a comment

Logging additional information like SessionID in every Log4j message

In his blog posts Log4j MDC (Mapped Diagnostic Context) : What and Why and Log4j MDC (Mapped Diagnostic Context) : Example code, Veera Sundar explains the concept of the Mapped Diagnostic Context (MDC), a thread-local key-value store that can be … Continue reading

Posted in Java Basics | Tagged , , , , | Leave a comment