Package de.galan.commons.logging
Class Say
java.lang.Object
de.galan.commons.logging.Say
Facade for the logging-framework (currently Log4j2). Uses the PayloadContextMessage for parameterization of messages.
Supports Parameterized messages, using {} as placeholder, eg.:
If the parameters should be available as json-encoded metadata for eg. logstash, you can provide names to the parameters. Example:
Additionally you can provide fields using a fluent interface using field(..) or f(..):
You can omit the curly braces in the message by setting the environment-variable SAY_FIELDS_ENCLOSED to "false".
info("Hello {}", "world"); // => "Hello {world}"
info("Hello {} {}", "beautiful", "world"); // => "Hello {beautiful} {world}"
error("Something failed: {}", ex, "do'h"); // => "Hello {beautiful} {world}"
If the parameters should be available as json-encoded metadata for eg. logstash, you can provide names to the parameters. Example:
info("Hello {location}", "world"); // ThreadContext will provide the json in a field called "payload"
Additionally you can provide fields using a fluent interface using field(..) or f(..):
Say.field("key", "value").field("other", someObject).info("Hello {location}", "world");
You can omit the curly braces in the message by setting the environment-variable SAY_FIELDS_ENCLOSED to "false".
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUsing fluent interface to construct ThreadContext informations (formerly known as MDC /NDC) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic Say.ContextBuilderstatic voidstatic voidstatic voidstatic voidstatic Say.ContextBuilderstatic voidstatic voidstatic voidstatic voidprotected static voidlog(org.apache.logging.log4j.Level level, Class<?> callerClass, Object message, Throwable throwable, Object... args) protected static org.apache.logging.log4j.message.Messagestatic voidplease()static voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic void
-
Constructor Details
-
Say
public Say()
-
-
Method Details
-
payload
-
log
-
f
-
field
-
trace
-
trace
-
trace
-
trace
-
debug
-
debug
-
debug
-
debug
-
info
-
info
-
info
-
info
-
warn
-
warn
-
warn
-
warn
-
error
-
error
-
error
-
error
-
fatal
-
fatal
-
fatal
-
fatal
-
please
public static void please()
-