papertrail / remote_syslog2

To install, see "Releases" tab. Self-contained daemon for reading local files and emitting remote syslog (without using local syslogd).
http://help.papertrailapp.com/
MIT License
637 stars 158 forks source link

Config option to append the filename to the tag #226

Open tterrace opened 5 years ago

tterrace commented 5 years ago

We have a use case where we'd like to glob all the files in several directories and give a unique tag to each, but also preserve the filenames in the log lines. For example, if we have a couple servers logging to multiple directories under /var/log, we could do something like:

files:
    - path: /var/log/frontend_server/*_log
      tag: frontend_server.
      appendPath: true
    - path: /var/log/backend_server/*_log
      tag: backend_server.
      appendPath: true

And the log lines would show up with the filenames (acceess_log/error_log) appended in papertrail:

Jul 24 14:31:44 i-080808ababab frontend_server.access_log: GET /
Jul 24 14:31:44 i-080808ababab frontend_server.error_log: ERROR: 
Jul 24 14:31:44 i-080808ababab backend_server.access_log: POST /
Jul 24 14:31:44 i-080808ababab backend_server.error_log: ERROR: 

I was able to hack my way into something that works, but I'm not a go programmer so it might not be the correct approach.

mfontani commented 1 year ago

I'd also really like this. I've a couple apps running on the same host and they log to different directories but to files with the same name (a number that increases at every app restart). This'd help me better identify which is which.