Skip to content

Instantly share code, notes, and snippets.

@BooookStore
Created January 2, 2020 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BooookStore/f77eac18f47bfbe0e76fa983cc507587 to your computer and use it in GitHub Desktop.
Save BooookStore/f77eac18f47bfbe0e76fa983cc507587 to your computer and use it in GitHub Desktop.
SLF4J output pattern
package com.example.slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GettingStartedSLF4J {
public static void main(String[] args) {
Logger logger = LoggerFactory.getLogger(GettingStartedSLF4J.class);
// [main] INFO com.example.slf4j.GettingStartedSLF4J - Hello, SLF4J!
logger.info("Hello, SLF4J!");
// [main] INFO com.example.slf4j.GettingStartedSLF4J - Hello, SLF4J with exception
// java.lang.Exception: failed message
// at com.example.slf4j.GettingStartedSLF4J.main(GettingStartedSLF4J.java:12)
logger.info("Hello, SLF4J with exception", new Exception("failed message"));
// [main] INFO com.example.slf4j.GettingStartedSLF4J - Hello, SLF4J with argument Arg1, Arg2
logger.info("Hello, SLF4J with argument {}, {}", "Arg1", "Arg2");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment