taoensso / timbre

Pure Clojure/Script logging library
https://www.taoensso.com/timbre
Eclipse Public License 1.0
1.44k stars 171 forks source link

[Syslog appender] How to log to /var/log/myapp.log? #318

Closed WorldsEndless closed 2 years ago

WorldsEndless commented 3 years ago

I'm almost there; I've got the syslog appender so I can log to places within /var/log; but how can I write to a file of my choosing? Instead it appears to just write to whichever pre-defined places syslog likes, when plenty of other apps can write to, e.g., "apache-error.log", etc.

WorldsEndless commented 3 years ago

Here is what I have so far.

(ns myapp.logging.log
  "ns for logging"
  (:require [taoensso.timbre :as log]
            [taoensso.timbre.appenders.3rd-party.syslog-appender]))

(comment
  ;; this write to whichever files syslog likes by default according to the :facility line, like /var/log/messages .
  ;; I'm still looking in to how to log to a file of our choosing
  (log/merge-config!
   {:appenders
    {:syslog-appender
     (taoensso.timbre.appenders.3rd-party.syslog-appender/syslog-appender
      {:ident "myapp"
       :syslog-options (byte 0x03)
       :facility :log-local6})}})

  (log/info "Testing syslog!"))
ptaoussanis commented 3 years ago

@WorldsEndless Hi Tory! I'm not too familiar with Syslog or this appender, but having a quick look over its code - doesn't seem to be any obvious Clojure-side option for this.

I suspect you might need to look through the Syslog call options and/or Syslog config docs to find what you need.

Another lead on Stack Overflow.

Hope that helps a bit, cheers!