Comments (6)
Also seeing this same issue. No matter what I do, I can't get request params to log at all.
from ring-logger.
Same problem.
from ring-logger.
Depending on what you are doing you probably need to add the :request-keys
to include maybe :body
for a post.
Also, if you really want to see what's in body you'll probably have to slurp the content to get it visible as text. Of course, this will have overhead so i'm only doing things like this in dev.
Maybe something like this:
(defn compile-middleware [app]
(-> app
(logger/wrap-log-request-params {:log-fn (fn [{:keys [level throwable message]}]
(timbre/info level message throwable))
:transform-fn #(-> %
(update-in [:message :body] slurp)
clojure.pprint/pprint)
:log-exceptions? true
:log-level :info
:request-keys [:request-method :uri :server-name :headers :body]})
maybe-wrap-basic-authentication
maybe-wrap-reload))
from ring-logger.
It looks like you need to parse the query params (using ring.middleware.params/wrap-params
). Ring doesn't parse the query string by default.
from ring-logger.
wrap-log-request-params
does work but I just spent a minute battling with this because I had forgotten it makes some assumptions and doesn't (quite) work out-of-the-box. Here are the two thing you need to keep in mind:
- Middleware Order: Make sure
wrap-params
happens beforewrap-log-request-params
in the middleware lifecycle. Remember the order is bottom-up if you're using the threading macro (->
). - Log Level: By default,
wrap-log-request-params
logs to:debug
and it's unlikely your local log config is set that high unless you're, well, debugging. Personally, I diagnose issues using param data all the time, so I bump the log level to:info
.
Examples of these two notes follow
- Middleware Order example
This fails:
(-> (handler)
wrap-log-response
wrap-keyword-params
wrap-params
wrap-log-request-params ;; FAILS: this happens too early in the middleware lifecycle
wrap-log-request-start)
This succeeds:
(-> (handler)
wrap-log-response
wrap-log-request-params ;; SUCCEEDS: the params have been parsed out of the request
wrap-keyword-params
wrap-params
wrap-log-request-start)
- Log Level example
You can either bump your log level to DEBUG or use :transform-fn
to adjust the log level of params logging before it hits the log-fn
. I prefer the latter, since DEBUG tends to be very noisy:
(wrap-log-request-params {:transform-fn (fn [m] (assoc m :level :info))})
Hopefully this saves someone a minute or two. :)
@nberger I think you can close this issue. Maybe some of the resolving comments could go into the docs?
from ring-logger.
@deobald thanks for helping out here. You are correct, wrap-log-request-params
depends on having wrap-params
to parse the params first. That's what the example does too.
I agree it would be great to put some of this into the docs. Unfortunately I'm not having too much time to actively maintain the project lately. I made you a collaborator in case you'd like to make those additions yourself.
Thanks!
from ring-logger.
Related Issues (20)
- wrap-with-body logger missing timbre HOT 3
- Some params & headers should be redacted before being logged to hide sensitive information HOT 1
- Exception thrown on query params without a value HOT 4
- Options to set log level for starting and finished HOT 2
- Started using timbre ring-logger and seeing a mysterious nil printed at the start of each log line HOT 4
- Avoid logging only request-params HOT 4
- Filter query string HOT 4
- Redacted key is not removed from URL HOT 1
- Ring-logger 1.0.0: Getting back to the roots HOT 3
- Rewrite README for 1.0.0 HOT 1
- Add parameters redaction on 0.8.x HOT 1
- Add documentation using codox
- Migration from 0.7 to 1.0 HOT 1
- wrap-log-response HOT 1
- No async support in 1.* version HOT 2
- Logging Request Body HOT 1
- Bump tools.logging to version 1.2.1 HOT 2
- Add a unique request-id as log context to identify multiple requests being logged concurrently
- Allow to disable logging of timing info
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ring-logger.