I have a logback.groovy that sends data to a logstash on the network with some custom fields:
appender("LOGSTASH", LogstashTcpSocketAppender) {
encoder(LogstashEncoder) {
customFields = """{ "token": "xxxxx", "environment":"dev", "some_property":"foobar" }"""
}
remoteHost = "logstashlistener.host.name"
port = 5000
}
So far so good. However, I need to cleanup some field names that are not valid for elasticsearch downstream. Based on the LogstashEncoder documentation, this can be achieved like this:
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<fieldNames>
<timestamp>time</timestamp>
<message>msg</message>
...
</fieldNames>
</encoder>
This seems great but I have to fit this into the logback.groovy notation.
I tried as a hashmap, string and more but always end up with Cannot cast object 'xxxx' with class 'xxxx' to class 'net.logstash.logback.fieldnames.LogstashFieldNames'