Last active
May 28, 2024 06:33
-
-
Save manios/cbe52788142bfa19b345b9bddbde4cca to your computer and use it in GitHub Desktop.
Stern template to format Spring Boot json logs into normal slf4j lockback text in Kubernetes. Used in https://manios.org/2023/06/18/kubernetes-view-pod-json-log-in-plain-text-with-stern-template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ printf "%-35s " .PodName -}} | |
{{ with $d := .Message | tryParseJSON -}} | |
{{ $myMessage := "" -}} | |
{{ $myStackTrace := "" -}} | |
{{ if $d.message -}} | |
{{ $myMessage = $d.message -}} | |
{{ end -}} | |
{{ if $d.stack_trace -}} | |
{{ $myStackTrace = $d.stack_trace -}} | |
{{ end -}} | |
{{ printf "%s %v %6.6s --- [%15.15s] %-70s : %s %s" (index $d "@timestamp") $d.level_value $d.level $d.thread_name $d.logger_name $myMessage $myStackTrace }}{{else}}{{ .Message }}{{"\n"}}{{end}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment