This is something that I would like to see added by default, since we are in RC phase I'll describe it here to decide if/when it should be added.
Using log4j (and also with slf4j) we can add useful informations to logs by adding some variables to MDC by default (mapped diagnostic context, see http://wiki.apache.org/logging-log4j/NDCvsMDC ).
Those additional info should be added by a filter. The code below shows what the filter should do (I am not attaching a proper patch since this is only for discussion). The filter should go exactly after the context filter (or we could decide to put it into the context filter maybe.
public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws IOException, ServletException
catch (Throwable e)
// whatever it happens, only log
Doing this, anywhere in the log4j.xml log patterns the following placeholders can be used in order to print out the current uri and the logged in user:
This looks very useful also in the mail appender, if you enable it in running sites.
This is an example of the content that can be added to error mails:
My Magnolia app
Number of occurrences: 2
[c020890-sun01] ERROR 23.02.2009 01:07:08 info.magnolia.module.exchangesimple.SimpleSyndicator SimpleSyndicator.java(run:77) -- Failed to activate content.
info.magnolia.cms.exchange.ExchangeException: Message received from subscriber: Activation failed | /NZ/large
.... (the usual stacktrace)
Although this can be easily implemented I think that at least the filter that pushes informations to log4j MDC should be added by default. What about adding it for 4.0?