[slf4j-dev] [Bug 116] Switching the log message format to that of java.util.Formatter
bugzilla-daemon at pixie.qos.ch
bugzilla-daemon at pixie.qos.ch
Thu Dec 4 18:16:40 CET 2008
http://bugzilla.slf4j.org/show_bug.cgi?id=116
--- Comment #28 from Ken Dobson <ken at magictractor.co.uk> 2008-12-04 18:16:39 ---
(In reply to comment #26)
> The first is supposedly accomplished because the parameters are no longer
> specified by "{}" but by the format expression along with the variable. This
> isn't I19N.
That's not the idea. I'll try to clarify matters.
An implementation of FormatModifier which performs I18N, would take a key like
"acc.bal" from logger.debug("acc.bal", bal) and map the key to a value like
"balance {}". The parameter values would be ignored by this FormatModifier and
the wrapped SLF4J Logger would perform the parameter substitution as usual.
Implementations of FormatModifier which perform alternative formatting do use
the parameter values when modifying the String. For example, with
logger.debug("balance %(,.2f", bal) the value of bal is used by the
FormatModifier, to create a new string such as "balance 123.45". The new
string is passed to the wrapped SLF4J Logger with the original parameter value
(123.45), but since there are no formatting anchors ("{}") the Logger does not
change the logged message.
It would be possible to use an alternative formatter and I18N together by
chaining FormatModifiers. For example, the first FormatModifier would change
the format from "acc.bal" to "balance %(,.2f", and the second FormatModifier
would change this to "balance 123.45" before passing it to the wrapped Logger.
(In reply to comment #25)
>> this whole discussion should be moved over to Logback
I disagree. If I'm working with a specific application and using Logback, then
yes, I'd rather use Logback's I18N support and vanilla Loggers. However, if I'm
writing a library and want to produce locale specific messages, then I don't
know what the backend will be.
There is scope for doing better things with Logback, but there should also be
some support for I18N in SLF4J extensions.
(In reply to comment #27)
>> It would "just" be necessary to format the *arguments*
This doesn't address Grzegorz's second point about being able to reorder
parameters in localized messages.
--
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the slf4j-dev
mailing list