Chef-client with logs

Dear All,

I want to start to working with logs.

For example, when i run chef client or run knife i want to export the errors to file and then to send it by email.

can anyone work me through?

thanks.

You can always just pipe the chef log to a text file

Just run check client with the debug or log level the way you want it i.e.

chef-client --log_level debug > c:\tmp\chef.log

that will pipe the results from the command line on windows to the chef.log file which you can then setup to be emailed. You can check for a failure message and send the email based on a failed run.

Redirecting output to a file and then parsing the file with grep or something would obviously work. But this is an exact use case for Chef Handlers.

https://docs.chef.io/handlers.html

ctrl-f for “A way to tell the chef-client how to send email”

Thanks for your reply…

i tried to work with Handler but it only receive this error “Chef run failed on node” without any detail of the error.
how can i add more information?

thanks