Rsyslog

Brian Pan
Apr 19, 2024

Multiline stack trace

# reference: https://www.datadoghq.com/blog/multiline-logging-guide/#rsyslog
# /etc/rsyslog.conf
# enable imfile
module(load="imfile" mode="inotify")
# /etc/rsyslog.d/12-worker.conf
# this will output stram to tag pm2-bom-worker by parsing the File
input(type="imfile"
tag="pm2-bom-worker: "
facility="local2"
severity="warn"
File="/var/log/supplyframe-fcl/worker-error.log"
time
startmsg.regex="^(\\S+)")

pm2

the local2 is the facility from above setup

$FileCreateMode 0644
template(name="DynFile" type="string" string="/var/log/webapp/%programname%.log")
template(name="pm2" type="list") {
property(name="timegenerated" dateFormat="rfc3339")
constant(value=" ")
property(name="hostname")
constant(value=" [")
property(name="syslogseverity-text")
constant(value="] ")
property(name="syslogtag")
property(name="msg")
constant(value="\n")
}

# change the level depends on env
local2.warn ?DynFile;pm2
& stop
local2.* stop

References

--

--