I am logging to Logback and have configured a Stackdriver Logging appender as follows:
<appender name="CLOUD" class="com.google.cloud.logging.logback.LoggingAppender">
<log>application.log</log>
<resourceType>generic_node</resourceType>
<flushLevel>INFO</flushLevel>
</appender>
Log entries are showing up in the Stackdriver Logging console:
{
insertId: "[...]"
labels: {
levelName: "INFO"
levelValue: "20000"
}
logName: "[...]"
receiveTimestamp: "2019-01-03T13:42:10.888423743Z"
resource: {
labels: {
location: ""
namespace: ""
node_id: ""
project_id: "[...]"
}
type: "generic_node"
}
severity: "INFO"
textPayload: "client disconnected"
timestamp: "2019-01-03T13:42:10.841Z"
}
However, I am missing information about the logger a log message originated from. Specifically, suppose I log a message like this:
import org.slf4j.LoggerFactory
val log = LoggerFactory.getInstance("component-a")
log.warn("temperature in hell fell below 100°C")
Then I would like to see that the log message came from the logger with the name "component-a". I found no mention of how to achieve this in the Stackdriver Logging documentation. I suppose I could configure a LoggingEnhancer
to enhance every log entry with the name of the logger, but I have no information about this logger while enhancing log entries.
Is there a (hopefully "canonical") solution to this?