Skip to content

Instantly share code, notes, and snippets.

View poy's full-sized avatar

Andrew Poydence poy

View GitHub Profile

Multi-line Java message workaround

Having log lines out of order can be painful when monitoring Java stack traces. There is a work around involving modifing the Java log output to have your app reformat your stacktrace messages so any newline characters are replaced by a token; and then have your log parsing code replace that token with newline characters again. The following example is for the Java Logback library and ELK, but you may be able to use the same strategy for other Java log libraries and log aggregators.

With the Java Logback library you do this by adding %replace(%xException){'\n','\u2028'}%nopex to your logging config , and then use the following logstash conf.

# Replace the unicode newline character \u2028 with \n, which Kibana will display as a new line.
    mutate {
      gsub => [ "[@message]", '\u2028', "
"]
@poy
poy / subcommands.go
Last active February 27, 2023 06:02
Simple Subcommands in Go
package subcommands
import (
"fmt"
"log"
"os"
"strings"
)
type Command interface {
package main
import (
"doppler/dopplerservice"
"errors"
"log"
"os"
"strings"
"github.com/cloudfoundry/gosteno"
@poy
poy / InstallJava8.sh
Created October 28, 2014 22:49
Testing ADD from url
#!/bin/bash -ex
OPENJDK8=openjdk-1.8
cd /tmp
rm -rf $OPENJDK8
mkdir $OPENJDK8
cd $OPENJDK8
# Grab latest URL