# Minimum amount of log file handling we can possibly get away with?

**URL:** https://forum.syncthing.net/t/minimum-amount-of-log-file-handling-we-can-possibly-get-away-with/1194
**Category:** Development
**Created:** [October 19, 2014, 12:58pm UTC](https://forum.syncthing.net/t/minimum-amount-of-log-file-handling-we-can-possibly-get-away-with/1194 "2014-10-19T12:58:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [October 19, 2014, 12:58pm UTC](https://forum.syncthing.net/t/minimum-amount-of-log-file-handling-we-can-possibly-get-away-with/1194/1 "2014-10-19T12:58:52Z")

</div>

All the useful patterns of running syncthing in the background on Windows discard the log output, and there’s no real practice around capturing stdout/stderr to log files as is fairly common under Unix. Hence the continuing confusion about where to get log data when asked. So as much as I loathe handling log data to files (I really do think that’s something better done by the OS), I think it’s necessary at least under Windows.

So I started by adding a `-logfile` flag, which gets swallowed by the monitor process who then simply redirects the regular log data to the named file.

> <https://github.com/syncthing/syncthing/commit/f4af9e9>

The question is, what more _must_ I do to make this acceptable?

Rotate log files per time or size? Or per program start? What’s the expected pattern here, primarily on Windows? (cc @AudriusButkevicius)

(I don’t want to implement a full syslog-ng as part of this 😁)

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [October 19, 2014, 1:43pm UTC](https://forum.syncthing.net/t/minimum-amount-of-log-file-handling-we-can-possibly-get-away-with/1194/2 "2014-10-19T13:43:03Z")

</div>

I guess truncate the log on start is more than enough.

Also, perhaps we’d want to tone down UPnP messages as that seems to be the only thing producing 3 lines every 30 minutes, otherwise I don’t see how the file could blow up.

Window’s itself has this evil CBS.log which grows indefinitely and though gets rotated usually fills up my SSD before it decides to clean it up.

Though I suggest to make `-logfile` is only available on Windows, not to encourage its use elsewhere.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [October 19, 2014, 3:19pm UTC](https://forum.syncthing.net/t/minimum-amount-of-log-file-handling-we-can-possibly-get-away-with/1194/3 "2014-10-19T15:19:56Z")

</div>

Makes sense. Pushed two more commits to [https://github.com/syncthing/syncthing/commits/windows-log-file](https://github.com/syncthing/syncthing/commits/windows-log-file).

---

<div class="post-metadata">

### Author: ![jpjp](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@jpjp](https://forum.syncthing.net/u/jpjp)
#### Post date: [October 19, 2014, 8:50pm UTC](https://forum.syncthing.net/t/minimum-amount-of-log-file-handling-we-can-possibly-get-away-with/1194/4 "2014-10-19T20:50:28Z")

</div>

_I guess truncate the log on start is more than enough._

Good idea, then the guide to getting it running as a service can recommend a restart.

But… this leaves it possible that the error is gone when the admin checks. So maybe one old log file should be kept.
