Logging
The Java SDK uses log4j2 as logging facade. To enable logging, add log4j2-core
to the dependencies. For example, for Gradle:
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
And configure the logging adding the file resources/log4j2.properties
:
# Set to debug or trace if log4j initialization is failingstatus = warn# Console appender configurationappender.console.type = Consoleappender.console.name = consoleLoggerappender.console.layout.type = PatternLayoutappender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %notEmpty{[%X{restateInvocationTarget}]}%notEmpty{[%X{restateInvocationId}]} %c - %m%n# Filter out logging during replayappender.console.filter.replay.type = ContextMapFilterappender.console.filter.replay.onMatch = DENYappender.console.filter.replay.onMismatch = NEUTRALappender.console.filter.replay.0.type = KeyValuePairappender.console.filter.replay.0.key = restateInvocationStatusappender.console.filter.replay.0.value = REPLAYING# Restate logs to debug levellogger.app.name = dev.restatelogger.app.level = infologger.app.additivity = falselogger.app.appenderRef.console.ref = consoleLogger# Root loggerrootLogger.level = inforootLogger.appenderRef.stdout.ref = consoleLogger
If you want to do filtering of the logs, you can use log4j2
filters.
Logging on the INFO
level is enough for most use cases, but you can set the log level of
the dev.restate
classes to DEBUG
and TRACE
if you want more info about the internal SDK operations.
The SDK injects the following additional metadata to the logging context that can be used for filtering as well:
restateInvocationTarget
: Invocation Target, e.g.counter.Counter/Add
.restateInvocationId
: Invocation ID.restateInvocationStatus
: Invocation status, can beWAITING_START
,REPLAYING
,PROCESSING
,CLOSED
.