Skip to content

Instantly share code, notes, and snippets.

@dayvonjersen
Created September 11, 2015 22:44
Show Gist options
  • Save dayvonjersen/569034c01a71ec41e8dd to your computer and use it in GitHub Desktop.
Save dayvonjersen/569034c01a71ec41e8dd to your computer and use it in GitHub Desktop.
Write your program's logs to their own file in /var/log with rsyslog
# In order to have your log messages which you wrote to syslog
# e.g. with go's log/syslog package:
#
# import (
# "log"
# "log/syslog"
# )
# //...
# if syslogw, err := syslog.New(syslog.LOG_NOTICE, "myprog"); err == nil {
# log.SetOutput(syslogw)
# }
#
# You can then have rsyslog write these messages to their own file(!) in /var/log
# You know, like a real, ~professional~ program would:
:programname, isequal, "myprog" /var/log/myprog.log
# peace, love and respect to:
# http://technosophos.com/2013/09/14/using-gos-built-logger-log-syslog.html
# http://unix.stackexchange.com/a/37235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment