Controlling Log4j Logs with Contexts and Filters

5 thoughts on “Controlling Log4j Logs with Contexts and Filters”

  1. That sure seems like an awful lot of code noise just to provide contextual logging. I think I’d just rather use grep and use a known log string prefix.

  2. @Caligula that would certainly work for basic filtering and this example is fairly basic. However, the context scale up considerably having nested contexts or mapped contexts with multiple values. Moreover, since these contexts are thread specific you can do things like separate processing of requests from multiple clients for example.

  3. I think that the NDC is a great way to seperate Logging. Especially try to log in an applicationserver like JBoss. To differentiate between several applications there are only some ways and the best I’ve met is the one using a context (for webapps it’s fairly easy to configure.)
    Great article.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s