Skip to content

Instantly share code, notes, and snippets.

@maroph
Created September 28, 2023 15:14
Show Gist options
  • Save maroph/723f395a68d532019217be7cd2a0150c to your computer and use it in GitHub Desktop.
Save maroph/723f395a68d532019217be7cd2a0150c to your computer and use it in GitHub Desktop.
SLF4J Simple Logging Setup
package mypackage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SimpleLogging {
static final Logger cLog;
static {
System.setProperty("org.slf4j.simpleLogger.showLogName", "true");
System.setProperty("org.slf4j.simpleLogger.showThreadName", "true");
System.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
// https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/SimpleDateFormat.html
System.setProperty("org.slf4j.simpleLogger.dateTimeFormat", "dd-MM-YYYY,kk:mm:ss.SSSZ");
// level: "off", "error", "warn", "info", "debug", "trace"
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info");
System.setProperty("org.slf4j.simpleLogger.log.mypackage", "debug");
cLog = LoggerFactory.getLogger(SimpleLogging.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment