Skip to content

Mini application to test multiline logs in OpenShift ELK stack

License

Notifications You must be signed in to change notification settings

bszeti/multiline-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multiline logging

Simple Java application (with Logback) that drops logs with line breaks and a stack trace on startup. The goal is to test how OpenShift/Kubernetes ELK stack can handle multiline logs.

Two main approaches:

Logstash-logback-encoder

Uses net.logstash.logback.encoder.LogstashEncoder encoder to format logs as JSON objects. Run with logback-logstash Spring profile to try, see logback-logstash.xml:

mvn -Dspring.profiles.active=logback-logstash clean spring-boot:run

The log lines are wrapped in JSON format including all the line breaks for a log event. Fluentd parses the JSON object fields and forwards the log event to Elasticsearch with the correct metadata fields: timestamp, level, logger, message.

Convert line breaks

Uses Logback’s %replace() feature to convert all '\n' (line feed - \u000D) to '\r' (carriage return - \u000A) characters. The log event is handled as one line on the Docker level, but line breaks look good in Kibana UI. Run with the default Spring profile to use logging pattern defined in application.yaml:

mvn clean spring-boot:run

Run with the logback-pattern Spring profile to use logback-pattern.xml:

mvn -Dspring.profiles.active=logback-pattern clean spring-boot:run

Use fabric8 maven profile to deploy on OpenShift:

mvn -P fabric8 -DskipTests clean install

This is designed to run in OpenShift. See run.sh with the small perl script that converts back '\r' to line ending if you want to try on localhost.

About

Mini application to test multiline logs in OpenShift ELK stack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published