Package com.cedarsoftware.util
Class LoggingConfig
java.lang.Object
com.cedarsoftware.util.LoggingConfig
Configures java.util.logging to use a uniform log format similar to
popular frameworks like SLF4J/Logback.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSimple formatter for tests that produces clean output similar to Maven's format:[LEVEL] messagestatic classFormatter producing logs in the pattern:yyyy-MM-dd HH:mm:ss.SSS [thread] LEVEL logger - message -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinit()Initialize logging if not already configured.static voidInitialize logging with the supplied date pattern if not already configured.static voidInitialize logging with simple format for tests (no timestamps, no thread names).static voiduseUniformFormatter(Handler handler) Set theLoggingConfig.UniformFormatteron the supplied handler.
-
Method Details
-
init
public static void init()Initialize logging if not already configured. The formatter pattern can be set via system property "ju.log.dateFormat" or by callinginit(String). If running in test environment (detected by system property), uses clean test format. -
initForTests
public static void initForTests()Initialize logging with simple format for tests (no timestamps, no thread names). Use this in test environments to get clean output similar to Maven's format. This method will force the test formatter even if logging was already initialized. -
init
Initialize logging with the supplied date pattern if not already configured.- Parameters:
datePattern- pattern passed toSafeSimpleDateFormat
-
useUniformFormatter
Set theLoggingConfig.UniformFormatteron the supplied handler.- Parameters:
handler- the handler to configure
-