6741 shaares
90 results
tagged
java
Localize your java Logger
Internationalize your java log messages almost for free.
Here's an example Foo.java:
import java.util.logging.Logger;
public class Foo {
private static final Logger LOG
= Logger.getLogger(Foo.class.getName(),
Foo.class.getName());
public static void main(String[] a) {
LOG.info("Everything is dandy."); // old way
LOG.info("dandy"); // new way
}
}
Create a Foo.properties file with this line
dandy=Everything is dandy.
in the same directory as Foo.class.
You'll see the same message twice.
Or create Foo_hick.properties with
dandy=Boy howdy.
and run
java -Duser.language=hick test.Foo
(Real languages use two-letter codes like en, es, ch, fr.)
Internationalize your java log messages almost for free.
Here's an example Foo.java:
import java.util.logging.Logger;
public class Foo {
private static final Logger LOG
= Logger.getLogger(Foo.class.getName(),
Foo.class.getName());
public static void main(String[] a) {
LOG.info("Everything is dandy."); // old way
LOG.info("dandy"); // new way
}
}
Create a Foo.properties file with this line
dandy=Everything is dandy.
in the same directory as Foo.class.
You'll see the same message twice.
Or create Foo_hick.properties with
dandy=Boy howdy.
and run
java -Duser.language=hick test.Foo
(Real languages use two-letter codes like en, es, ch, fr.)