canton7 / SyncTrayzor

Windows tray utility / filesystem watcher / launcher for Syncthing
MIT License
5.91k stars 407 forks source link

Massive logs #42

Closed AudriusButkevicius closed 9 years ago

AudriusButkevicius commented 9 years ago

https://github.com/syncthing/syncthing/issues/1579#issuecomment-89516413

canton7 commented 9 years ago

@borissamardzija That's an impressively large logfile! It will be automatically deleted after a week, but I agree it should never get that large in the first place. It looks like Syncthing's logging an awful lot to stdout, which SyncTrayzor is capturing: the syncthing.xxxx.log logfiles are a record of stdout. Normally syncthing only logs a lot if something's gone a bit wrong - can you take a look inside the logfile and give me a representative snippet?

So, there's about 2GB of stdout logs, and the rest is probably mainly Syncthing's events.

I don't want to stop logging Syncthing's stdout - it's important information. However, we can tweak the log rotation config so they get archived, and then deleted, more frequently.

I'll fix this in the next release. In the meantime, you can:

  1. Open C:\Program Files\SyncTrayzor\SyncTrayzor.exe.config (or if you've got the portable version, SyncTrayzor.exe.config)
  2. Replace the <nlog ... > section at the bottom with:
    <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <targets>
        <target name="logfile" type="File"
                fileName="${gdc:item=LogFilePath}\SyncTrayzor.log"
                createDirs="True"
                archiveFileName="${gdc:item=LogFilePath}\logs archive\SyncTrayzor.{#}.log"
                archiveAboveSize="10485760"
                archiveEvery="Day"
                archiveNumbering="Sequence"
                maxArchiveFiles="5"
                AutoFlush="True"
                layout="${longdate} [${level}] ${logger}: ${message} ${exception:format=type,message,method,stacktrace,tostring:maxInnerExceptionLevel=10:innerFormat=shortType,message,method}"/>
        <target name="debugger" type="Debugger"
                layout="${time} [${level}] ${logger:shortName=true} ${message}"/>
        <target name="syncthinglogfile" type="file"
                fileName="${gdc:item=LogFilePath}\syncthing.log"
                createDirs="True"
                archiveFileName="${gdc:item=LogFilePath}\logs archive\syncthing.{#}.log"
                archiveAboveSize="10485760"
                archiveEvery="Day"
                archiveNumbering="Sequence"
                maxArchiveFiles="5"
                layout="${message}"/>
      </targets>
      <rules>
        <logger name="SyncTrayzor.SyncThing.SyncThingProcessRunner" minlevel="Debug" writeTo="syncthinglogfile"/>
        <logger name="*" minlevel="Debug" writeTo="logfile"/>
        <logger name="*" minlevel="Debug" writeTo="debugger"/>
      </rules>
  </nlog>

Then delete the logs archive folder.

That will limit the disk usage of SyncTrayzor's logs to 100MB, and that's in extreme cases (with lots of stdout output).

bbrdaric commented 9 years ago

Yes, I was also shocked when I found this.

It's caused by https://github.com/syncthing/syncthing/issues/1295 https://github.com/syncthing/syncthing/issues/504

so my log files consist mainly of someting like this [7DEKR] 00:52:30 INFO: Puller (folder "Cloud", file "Dropbox\\Apps\\Money by Jumsoft\\com.jumsoft.money3.sync\\Documents\\45454E72-D091-449A-9307-52D4E13A8F1B\\SyncChanges\\B2E23A5C-17A1-4962-B1DC-BEB9E4654180-222-000000498A607DDB\\0439059709,110088-EC55D290-B456-4C41-BE55-86999B485109-27232-00001143122A365D.syncchg"): dst create: open D:\Cloud\Dropbox\Apps\Money by Jumsoft\com.jumsoft.money3.sync\Documents\45454E72-D091-449A-9307-52D4E13A8F1B\SyncChanges\B2E23A5C-17A1-4962-B1DC-BEB9E4654180-222-000000498A607DDB\~syncthing~.0439059709,110088-EC55D290-B456-4C41-BE55-86999B485109-27232-00001143122A365D.syncchg.tmp: The system cannot find the path specified.

The problem is, that line is generated about 400 times a second!

I will now try what you suggested and get back with results.

Thank you for support!

canton7 commented 9 years ago

Cool - the new config will rotate the logs after they reach 10MB, and reduces the number of archived files to 5. So the max you can end up with is 5 10MB for SyncTrayzor and 5 10MB for Syncthing. I don't want to keep less than that in case I need to debug a user issue.

bbrdaric commented 9 years ago

You mean, 5x10MB for SyncTrayzor and 5x10MB for Syncthing

Yup, I filled that already so I think this works fine now! :)

2

canton7 commented 9 years ago

Cool, thanks for testing that! The next release will make this the default