Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use set-config! to output to a file #161

Closed
chrismurrph opened this issue Apr 13, 2016 · 11 comments
Closed

How to use set-config! to output to a file #161

chrismurrph opened this issue Apr 13, 2016 · 11 comments

Comments

@chrismurrph
Copy link

A few people don't know how to log to a file. Here's my SO question:

http://stackoverflow.com/questions/36588781/timbre-set-config-has-changed-arity-thus-dont-know-how-to-use-it-to-output-s

Here's another identical one (so mine might not last):

http://stackoverflow.com/questions/35639153/clojure-timbre-4-0-set-config

@ptaoussanis
Copy link
Member

Hi Chris,

Usage of the spit (file) appender is documented in the README at https://github.com/ptaoussanis/timbre#file-appender

Hope that helps, cheers!

@chrismurrph
Copy link
Author

Hi Peter,
Thanks. I'll work it out and post the answer to SO.

@ptaoussanis
Copy link
Member

Sorry Chris, not sure I follow what needs working out?

The README gives an example that you should be able to just copy+paste, no? Or do you specifically want to use the set-config!?

@chrismurrph
Copy link
Author

True - it was copy/paste: it works. The thing is to me 'appenders' seemed
like something advanced. Hence I skipped over them in the documentation and
assumed something would need to be 'worked out' in order to use them.

On 13 April 2016 at 15:19, Peter Taoussanis notifications@github.com
wrote:

Sorry Chris, not sure I follow what needs working out?

The README gives an example that you should be able to just copy+paste,
no? Or do you specifically want to use the set-config!?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#161 (comment)

@ptaoussanis
Copy link
Member

True - it was copy/paste: it works.

Great, thanks for the confirmation.

The thing is to me 'appenders' seemed
like something advanced. Hence I skipped over them in the documentation and
assumed something would need to be worked out to use them.

Understood, no problem.

Fwiw, there's no magic going on underneath. Timbre's config's just one big map as in https://github.com/ptaoussanis/timbre#configuration. You can modify the map using Clojure's standard utils like assoc, merge, assoc-in, etc.

Cheers :-)

@chrismurrph
Copy link
Author

Something I just noticed is that the messages are now going to the file and to the console, whereas in the legacy example I'm pretty sure the output was going to just the file. So next part of the question is how to turn output to console/REPL off.

@ptaoussanis
Copy link
Member

The stdout appender is located at [:appenders :println] and is enabled by default.

(timbre/merge-config!
  {:appenders
   {:println nil ; Remove println appender
    :spit (appenders/spit-appender {:fname "/path/my-file.log"})}})

Will do the trick

@chrismurrph
Copy link
Author

That doesn't work for me.

@ptaoussanis
Copy link
Member

You might need to provide some more details than "that doesn't work".

Unfortunately going to need to sign off on this issue, have my hands a bit full atm. Would encourage you to check out the docs, otherwise someone else on here should hopefully be able to assist.

Best of luck, cheers! :-)

@chrismurrph
Copy link
Author

Adding the mapentry :println nil to the config hash map has no effect for me. This means that output goes to the console as well as to the file. I expected the output to go only to the file.

@chrismurrph
Copy link
Author

Thanks for confirming andreasthoelke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants