# Windows Agent - logfile

**URL:** <https://community.icinga.com/t/windows-agent-logfile/1331>\
**Category:** Icinga 2\
**Created:** [May 27, 2019, 1:30pm UTC](https://community.icinga.com/t/windows-agent-logfile/1331 "2019-05-27T13:30:49Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![phil-or](https://community.icinga.com/user_avatar/community.icinga.com/phil-or/32/783_2.png) [@phil-or](https://community.icinga.com/u/phil-or)\
**Post date:** [May 27, 2019, 1:30pm UTC](https://community.icinga.com/t/windows-agent-logfile/1331/1 "2019-05-27T13:30:49Z")

</div>

Hello!  
We are using the Windows Agent on many servers and now the icinga.log file gets bigger and bigger.  
Is there a setting to limit the size of the log file?  
What is best practice for this case?

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [May 27, 2019, 1:59pm UTC](https://community.icinga.com/t/windows-agent-logfile/1331/2 "2019-05-27T13:59:00Z")

</div>

Hi,

on Linux/Unix we recommend to use logrotate, on Windows there is no such thing OOTB to my knowledge. You may create your own PS script which stops the service, renames and/or zips the log files and then start the service again.

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![phil-or](https://community.icinga.com/user_avatar/community.icinga.com/phil-or/32/783_2.png) [@phil-or](https://community.icinga.com/u/phil-or)\
**Post date:** [May 27, 2019, 2:34pm UTC](https://community.icinga.com/t/windows-agent-logfile/1331/3 "2019-05-27T14:34:45Z")

</div>

I almost thought so…  
Thx Michael!

---

<div class="post-metadata">

**Author:** ![blakehartshorn](https://community.icinga.com/user_avatar/community.icinga.com/blakehartshorn/32/599_2.png) [@blakehartshorn](https://community.icinga.com/u/blakehartshorn)\
**Post date:** [May 27, 2019, 4:03pm UTC](https://community.icinga.com/t/windows-agent-logfile/1331/4 "2019-05-27T16:03:54Z")

</div>

Do it as an event handler!

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [May 27, 2019, 4:13pm UTC](https://community.icinga.com/t/windows-agent-logfile/1331/5 "2019-05-27T16:13:54Z")

</div>

I strongly advise against doing such things via the core’s event handler. If this goes nuts, or rotation fails for some reason, the agent won’t be revived again.

---

<div class="post-metadata">

**Author:** ![blakehartshorn](https://community.icinga.com/user_avatar/community.icinga.com/blakehartshorn/32/599_2.png) [@blakehartshorn](https://community.icinga.com/u/blakehartshorn)\
**Post date:** [May 27, 2019, 4:26pm UTC](https://community.icinga.com/t/windows-agent-logfile/1331/6 "2019-05-27T16:26:41Z")

</div>

Fiiiine, I’ll stop promoting bad (fun) ideas in production.

---

<div class="post-metadata">

**Author:** ![anon66228339](https://community.icinga.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@anon66228339](https://community.icinga.com/u/anon66228339)\
**Post date:** [May 27, 2019, 6:41pm UTC](https://community.icinga.com/t/windows-agent-logfile/1331/7 "2019-05-27T18:41:25Z")

</div>

I disable log on windows agents mostly. Only fir debugging i enable it.

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [May 28, 2019, 6:53am UTC](https://community.icinga.com/t/windows-agent-logfile/1331/8 "2019-05-28T06:53:15Z")

</div>

To be fair - there’s a feature request open, but I don’t know how to implement it properly. That may or may not be a good candidate for a better logging library as well.

> <https://github.com/Icinga/icinga2/issues/4815>

---

<div class="post-metadata">

**Author:** ![blakehartshorn](https://community.icinga.com/user_avatar/community.icinga.com/blakehartshorn/32/599_2.png) [@blakehartshorn](https://community.icinga.com/u/blakehartshorn)\
**Post date:** [May 28, 2019, 11:40am UTC](https://community.icinga.com/t/windows-agent-logfile/1331/9 "2019-05-28T11:40:16Z")

</div>

Are you worried about potential memory overflow by caching while renaming the file and creating a new one? Probably no issue on clients. Baby might fall down go boom on a master with debug on. The .1 .2 .3 .4 .5 thing could work. Ugly as sin but it could work.

Also, potentially a module to just push errors to the windows event log.

Either way, I now realize I need a check for that file’s size.

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [May 28, 2019, 11:57am UTC](https://community.icinga.com/t/windows-agent-logfile/1331/10 "2019-05-28T11:57:07Z")

</div>

I’m more worried about event handlers and their purpose and interface. They’re run on state changes, and you cannot rely on that specifically. Now comes the argument to run the check more often then, but seriously, I wouldn’t stress a Windows client with dummy results just for doing some IO tasks. Users will complain about this.

I prefer cronjobs and scheduler services for such a fixed rotation or anything else which must be done outside of the actual monitoring core.

If you google a bit, you’ll find [examples](https://stackoverflow.com/questions/3535989/log-rotation-for-nginx-on-windows) for this. I wouldn’t bother with signal handling though, just stop and start the Windows service again.

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![blakehartshorn](https://community.icinga.com/user_avatar/community.icinga.com/blakehartshorn/32/599_2.png) [@blakehartshorn](https://community.icinga.com/u/blakehartshorn)\
**Post date:** [May 28, 2019, 12:11pm UTC](https://community.icinga.com/t/windows-agent-logfile/1331/11 "2019-05-28T12:11:34Z")

</div>

Oh I was just spitballing on an actual implementation regarding the feature request. Doing that as an event handler would be a nightmare.

I should maybe check and see just how modular that is. I might get bored enough to tinker.
