Fork me on GitHub
#pedestal
<
2020-06-30
>
erwinrooijakkers11:06:08

Hi because of a health check I see every second logging like this:

{"message":"{:msg \"GET /\", :line 80}","severity":"INFO","thread":"qtp1569164069-15","logger":"io.pedestal.http"}

erwinrooijakkers11:06:27

Is there a way to modify the logger in such a way that requests to “\/” are ignored?

lanejo0113:06:29

@erwinrooijakkers change your logback.xml file to change the log level that is reported to be above "INFO"

erwinrooijakkers13:06:23

The thing is I do want other INFO logging

erwinrooijakkers13:06:28

Other requests are fine

erwinrooijakkers13:06:37

Only not GET requests to /

erwinrooijakkers13:06:08

I think it can be done by modifying the request-logger

erwinrooijakkers13:06:53

Default is this:

(def log-request
  "Log the request's method and uri."
  (interceptor/on-request
    ::log-request
    (fn [request]
      (log/info :msg (format "%s %s"
                             (string/upper-case (name (:request-method request)))
                             (:uri request)))
      (log/meter ::request)
      request)))

erwinrooijakkers13:06:06

So I can change that one to check the :uri and then not log. 🙂

ivar.refsdal09:07:56

That's seems fine I think

ivar.refsdal09:07:01

On my service-map I'm doing pretty much exactly that:

; [io.pedestal.http :as http]
(assoc ::http/request-logger weblog/log-request)
and
(def log-request
  "Log the request's method and uri."
  (helpers/on-request
    ::log-request
    (fn [request]
      (when (not= "/graphql-ws" (:uri request))
        (ped-log/info :msg (format "%s %s"
                                   (str/upper-case (name (:request-method request)))
                                   (:uri request)))
        (ped-log/meter ::request))
      request)))
Pretty similar to your case

lanejo0114:06:54

I really think you should make that change in the logback.xml, but I don't know the details off the top of my head. This sounds like it should be a configuration change though, not a code change.

erwinrooijakkers16:06:06

Uhm well logback only has access to the string content. It might be able to create a filter based on a regex.

danvingo14:06:27

you could decorate the default request-logger and then pass yours in when you create the service https://github.com/pedestal/pedestal/blob/master/service/src/io/pedestal/http.clj#L205