The branch, master has been updated via d0bd0734e5b9dd7180a24337c430bf9a73624aa3 (commit) from 0b0a9926facc8f1b5c06ef2ff63bb68e7d60db5a (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://git.qos.ch/gitweb/?p=slf4j.git;a=commit;h=d0bd0734e5b9dd7180a24337c430bf9a73624aa3 http://github.com/ceki/slf4j/commit/d0bd0734e5b9dd7180a24337c430bf9a73624aa3 commit d0bd0734e5b9dd7180a24337c430bf9a73624aa3 Author: Ceki Gulcu <c...@qos.ch> Date: Wed Sep 30 14:40:32 2009 +0200 - added blurb on MessageFormat conventions diff --git a/slf4j-site/src/site/pages/localization.html b/slf4j-site/src/site/pages/localization.html index e9840a3..56b6c0b 100644 --- a/slf4j-site/src/site/pages/localization.html +++ b/slf4j-site/src/site/pages/localization.html @@ -42,7 +42,7 @@ href="http://cal10n.qos.ch/apidocs/ch/qos/cal10n/IMessageConveyor.html">IMessageConveyor</a> instance, you can create a <a href="xref/org/slf4j/cal10n/LocLoggerFactory.html">LocLoggerFactory</a>, - which in turn can create a <a + which in turn can create <a href="xref/org/slf4j/cal10n/LocLogger.html">LocLogger</a> instances capable of doing localized logging. </p> @@ -69,7 +69,16 @@ public enum Production { }</pre> <p>It is assumed that you have created appropriate bundle file for - the various locales "en_UK" and "ja_JP" as appropriate. Then, you + the various locales "en_UK" and "ja_JP" as appropriate. Here is a + sample bundle for the "en_UK" locale. + </p> + + + <pre class="source">APPLICATION_STARTED=Application <b>{0}</b> has started. +APPLICATION_STOPPED=Application <b>{0}</b> has stopped. +... </pre> + + <p>Then, you can instantiate a <code>IMessageCoveyor</code>, inject it into a <code>LogLoggerFactory</code>, retreive multiple <code>LogLogger</code> instances by name and log away, as the next @@ -88,7 +97,7 @@ import ch.qos.cal10n.MessageConveyor; public class MyApplication { // create a message conveyor for a given locale - IMessageConveyor messageConveyor = new MessageConveyor(Locale.JAPAN); + IMessageConveyor messageConveyor = new MessageConveyor(Locale.UK); // create the LogLoggerFactory LocLoggerFactory llFactory_uk = new LocLoggerFactory(messageConveyor); @@ -98,24 +107,51 @@ public class MyApplication { public void applicationStart() { - locLogger.info(Production.APPLICATION_STARTED); + locLogger.info(Production.APPLICATION_STARTED, "fooApp"); // .. } public void applicationStop() { - locLogger.info(Production.APPLICATION_STOPPED); + locLogger.info(Production.APPLICATION_STOPPED, "fooApp"); // ... } }</pre> - <p>Assuming the resource bundle <em>production_jp.properties</em> - exists, and the underlying logging framework is enabled for the - info level, log messages in Japenese will be output. + <p>Assuming the resource bundle + <em>production_en_UK.properties</em> exists, and the underlying + logging framework is enabled for the info level, log messages will + be output in UK English. </p> <p>Note that a <code>LogLogger</code> is a regular SLF4J logger - with additional methods supporting localization.</p> + with additional methods supporting localization. For those + additional methods which take an enum as first parameter, + <code>LogLogger</code> follows the standard Java convention for + parameter substitution as defined by the <a + href="http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html">java.text.MessageFormat</a> + class. For non-localized logs, which take a String as first + parameter, <code>LogLogger</code> follows the {} convention, as + customary for all <code>org.slf4j.Logger</code> implementations. + </p> + <p>Here is an example illustrating the difference.</p> + + <pre class="prettyprint source">import ...; +public class MyApplication { + + IMessageConveyor messageConveyor = new MessageConveyor(Locale.UK); + LocLoggerFactory llFactory_uk = new LocLoggerFactory(messageConveyor); + LocLogger locLogger = llFactory_uk.getLocLogger(this.getClass()); + + public void someMethod() { + // follows the MessageFormat convention + locLogger.info(Production.APPLICATION_STARTED, "fooApp"); + + // follows the {} convention + logLogger.ingo("Hello {}", name); + ... + } +}</pre> <script src="templates/footer.js" type="text/javascript"></script> </div> </body> ----------------------------------------------------------------------- Summary of changes: slf4j-site/src/site/pages/localization.html | 54 ++++++++++++++++++++++---- 1 files changed, 45 insertions(+), 9 deletions(-) hooks/post-receive -- SLF4J: Simple Logging Facade for Java _______________________________________________ dev mailing list dev@slf4j.org http://www.slf4j.org/mailman/listinfo/dev