# Log rotation for chef client on Windows

**URL:** https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516
**Category:** Chef Infra (archive)
**Created:** [February 11, 2019, 8:27pm UTC](https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516 "2019-02-11T20:27:11Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![elikatz](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@elikatz](https://discourse.chef.io/u/elikatz)
#### Post date: [February 11, 2019, 8:27pm UTC](https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516/1 "2019-02-11T20:27:11Z")

</div>

Hello all,  
I've noticed that our chef-client log is huge on some of our servers.  
Looks like non-Windows has a build in log rotate - is there a similar solution for windows?

Regardless to the rotation, is it possible to send the logs to a local file and to a syslog server?

Thanks!

---

<div class="post-metadata">

### Author: ![elikatz](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@elikatz](https://discourse.chef.io/u/elikatz)
#### Post date: [March 1, 2019, 2:50pm UTC](https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516/2 "2019-03-01T14:50:39Z")

</div>

Any thoughts?  
I found a logrotate cookbook for Windows - is that the right solution? does it know to deal with a locked log in case Chef client is running?

---

<div class="post-metadata">

### Author: ![nkadel](https://avatars.discourse-cdn.com/v4/letter/n/5f9b8f/32.png) [@nkadel](https://discourse.chef.io/u/nkadel)
#### Post date: [March 4, 2019, 2:14am UTC](https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516/3 "2019-03-04T02:14:06Z")

</div>

To quote a Sunday morning cartoon of my youth.

"Hey, Rocky, watch me pull a logfile out of my hat!"

"Bullwinkle, that trick never works!!!"

If the logrotate is a scheduled task that happens _apart_ from runs of chef-client, then yes, that could work. If not, then it could be trying to rolocate the file that the task, itself, is writing to. Windows based filesystems do not deal with this well.

---

<div class="post-metadata">

### Author: ![bcorner\_fan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bcorner_fan/32/2237_2.png) [@bcorner\_fan](https://discourse.chef.io/u/bcorner_fan)
#### Post date: [March 4, 2019, 12:53pm UTC](https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516/4 "2019-03-04T12:53:19Z")

</div>

I use the chef-client cookbook to enforce settings. There are parameters for logging setup

> <https://github.com/chef-cookbooks/chef-client/blob/master/README.md>

---

<div class="post-metadata">

### Author: ![elikatz](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@elikatz](https://discourse.chef.io/u/elikatz)
#### Post date: [March 4, 2019, 5:01pm UTC](https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516/5 "2019-03-04T17:01:30Z")

</div>

🙂  
How do you take care of log rotation on windows clients?  
I'll give that cookbook a try...  
([https://supermarket.chef.io/cookbooks/windows\_logrotate#readme](https://supermarket.chef.io/cookbooks/windows_logrotate#readme))

---

<div class="post-metadata">

### Author: ![elikatz](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@elikatz](https://discourse.chef.io/u/elikatz)
#### Post date: [March 4, 2019, 5:02pm UTC](https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516/6 "2019-03-04T17:02:19Z")

</div>

I don't think that log rotation using the chef client cookbook is working on Windows... we are using that cookbook and its not rotating the logs...

---

<div class="post-metadata">

### Author: ![bcorner\_fan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bcorner_fan/32/2237_2.png) [@bcorner\_fan](https://discourse.chef.io/u/bcorner_fan)
#### Post date: [March 5, 2019, 2:38pm UTC](https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516/7 "2019-03-05T14:38:11Z")

</div>

I didn’t realize you were using windows. Currently logrotate doesn’t support windows only \*nix platforms.

[https://github.com/chef-cookbooks/chef-client/issues/451](https://github.com/chef-cookbooks/chef-client/issues/451)

found this tool. Not sure if it will work for you though. [LogRotateWin download | SourceForge.net](https://sourceforge.net/projects/logrotatewin/)

![](https://sea2.discourse-cdn.com/flex016/images/transparent.png)

---

<div class="post-metadata">

### Author: ![elikatz](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@elikatz](https://discourse.chef.io/u/elikatz)
#### Post date: [March 5, 2019, 9:02pm UTC](https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516/8 "2019-03-05T21:02:08Z")

</div>

Yes, that cookbook on supertmarket is based on that link you provided:  
[https://supermarket.chef.io/cookbooks/windows\_logrotate#readme](https://supermarket.chef.io/cookbooks/windows_logrotate#readme)

---

<div class="post-metadata">

### Author: ![elikatz](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@elikatz](https://discourse.chef.io/u/elikatz)
#### Post date: [March 15, 2019, 2:45pm UTC](https://discourse.chef.io/t/log-rotation-for-chef-client-on-windows/14516/9 "2019-03-15T14:45:48Z")

</div>

Wanted to update that this cookbook works pretty well! only thing that i couldn't figure out is a way to make it zip the files rather then gz (which is not a big deal but not as easy to work with in case we need to troubleshoot).  
when using zip extension the file get corrupted.
