logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Endre StĂžlsvik <En...@Stolsvik.com>
Subject Re: Experimental log4j formatter in sandbox
Date Fri, 13 Jan 2006 13:16:12 GMT
| 
| One of my concerns was introducing yet another pattern syntax when Java class
| libraries already have two (java.text.MessageFormat and java.util.Formatter).
| I had originally thought that the substitution pattern format was a subset of
| that supported by java.text.MessageFormat, 

same here..

| however java.text.MessageFormat
| would require parameter numbers within the braces (for example, "The {0}
| jumped over the moon {1} times").

..

The whole point of using explicit positions, is that in some languages, 
the order of the two elements would be changed. So if you want localized 
formatting/logging, the {} won't cut it.

I just made a set of methods for text-formatting in our portal-framework. 
I think that MessageFormat is too complex, so I turned to log4j to look at 
the approach there, and possibly loan some code. However, that won't cut 
it either, since this approach doesn't take into account the fact about 
languages' differences in word ordering. I ended up making a system that 
combines the two: A "{}" chooses the /first available/ variable, while {x} 
explicitly specifies one.

Thus, "{} {} {}" == "{0} {1} {2}" (most normal case), "{1} {} {}" == "{1} 
{0} {2}" (some language that requires that subject and object is changed?) 
and "{} {} {0}" == "ERROR".

Regards,
Endre.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message