public final class MessageResolver extends Object implements EventResolver
Message resolver.
config = [ stringified ] , [ fallbackKey ] stringified = "stringified" -> boolean fallbackKey = "fallbackKey" -> string
{
"$resolver": "message",
"stringified": true
}
Resolve the message such that if it is a ObjectMessage or MultiformatMessage with JSON support, its emitted JSON type (string, list,
object, etc.) will be retained:
{
"$resolver": "message"
}
Given the above configuration, a SimpleMessage will generate a
"sample log message", whereas a MapMessage will generate a
{"action": "login", "sessionId": "87asd97a"}. Certain indexed log
storage systems (e.g., Elasticsearch) will not
allow both values to coexist due to type mismatch: one is a string
while the other is an object. Here one can use a
fallbackKey to work around the problem:
{
"$resolver": "message",
"fallbackKey": "formattedMessage"
}
Using this configuration, a SimpleMessage will generate a
{"formattedMessage": "sample log message"} and a MapMessage
will generate a {"action": "login", "sessionId": "87asd97a"}. Note
that both emitted JSONs are of type object and have no
type-conflicting fields.| Modifier and Type | Method and Description |
|---|---|
void |
resolve(LogEvent logEvent,
JsonWriter jsonWriter)
Resolves the given
value using the provided JsonWriter. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisFlattening, isResolvable, isResolvable, resolvepublic void resolve(LogEvent logEvent, JsonWriter jsonWriter)
TemplateResolvervalue using the provided JsonWriter.resolve in interface TemplateResolver<LogEvent>Copyright © 1999-1969 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.