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 class
Simple formatter for tests that produces clean output similar to Maven's format:[LEVEL] message
static class
Formatter producing logs in the pattern:yyyy-MM-dd HH:mm:ss.SSS [thread] LEVEL logger - message
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
init()
Initialize logging if not already configured.static void
Initialize logging with the supplied date pattern if not already configured.static void
Initialize logging with simple format for tests (no timestamps, no thread names).static void
useUniformFormatter
(Handler handler) Set theLoggingConfig.UniformFormatter
on 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.UniformFormatter
on the supplied handler.- Parameters:
handler
- the handler to configure
-