[logback-dev] MessageFormatter

Ceki Gülcü ceki at qos.ch
Wed Jan 20 20:11:57 CET 2010


Hello,

As far as the requirements you have described, assuming you are using
PatternLayout to format the output, you can easily create your own
conversion specifier (see [1]) to format the message according to your
wishes. You are not forced to use %m / %msg / %message in your
conversion pattern.

For example, assuming you defined %myMsg the conversion word, you
could have "%d %level - %myMsg%n" as your conversion pattern, which
would 1) appendall arguments lacking an associated {}, 2) allow
special formatting of arguments of certain types.

Would the above work for you?

[1] http://logback.qos.ch/manual/layouts.html#customConversionSpecifier

On 18/01/2010 1:39 PM, Ruediger zu Dohna wrote:
> Hi!
>
> Logback has two levels of formatting: One for the complete log entry and
> one for the log message itself. While it's flexible with the first, it's
> restrictive with the second, as the MessageFormatter class is right now
> a static-methods-only singleton. By making it an interface with a
> default implementation, one could reconfigure a Layout to use a
> different Formatter with other features.
>
> We'd like to have a message formatter that:
> 1. Appends all arguments that don't have a formatting anchor ("{}").
> 2. Configurably allow special formatting of arguments of some class.
>
> The workaround we are living with now is to use mainly a copy of the
> current MessageFormatter class.
>
> Before I file an JIRA entry and maybe even provide a patch, I'd like to
> know what others think.
>
>
> Regards
>


More information about the logback-dev mailing list