Skip to content

Instantly share code, notes, and snippets.

@markscottwright
Last active July 17, 2022 09:29
Show Gist options
  • Save markscottwright/5bf95f3ec0c9b0217b683d331e6e8ecd to your computer and use it in GitHub Desktop.
Save markscottwright/5bf95f3ec0c9b0217b683d331e6e8ecd to your computer and use it in GitHub Desktop.

java.util.logging tips

The format can be set on the command line using -Djava.util.logging.SimpleFormatter.format="XXX". Or it can be set like this programmatically:

static
{
    System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tF %1$tT.%1$tL %4$s %2$s %5$s%6$s%n");
}

If setting programmatically, be sure to do it before any logging code is called (hence the static block).

slf4j

If using slf4j, or using a library that uses slf4j, this is the way to direct the slf4j logging facade to the JUL backend:

<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>slf4j-jdk14</artifactId>
	<version>${slf4jVersion}</version>
</dependency>

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment