{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/37200","repository_url":"https://api.github.com/repos/saltstack/salt","labels_url":"https://api.github.com/repos/saltstack/salt/issues/37200/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/37200/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/37200/events","html_url":"https://github.com/saltstack/salt/pull/37200","id":184958173,"number":37200,"title":"Windows: Add log file rotation support","user":{"login":"skizunov","id":11562452,"avatar_url":"https://avatars.githubusercontent.com/u/11562452?v=3","gravatar_id":"","url":"https://api.github.com/users/skizunov","html_url":"https://github.com/skizunov","followers_url":"https://api.github.com/users/skizunov/followers","following_url":"https://api.github.com/users/skizunov/following{/other_user}","gists_url":"https://api.github.com/users/skizunov/gists{/gist_id}","starred_url":"https://api.github.com/users/skizunov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skizunov/subscriptions","organizations_url":"https://api.github.com/users/skizunov/orgs","repos_url":"https://api.github.com/users/skizunov/repos","events_url":"https://api.github.com/users/skizunov/events{/privacy}","received_events_url":"https://api.github.com/users/skizunov/received_events","type":"User","site_admin":false},"labels":[{"id":77737132,"url":"https://api.github.com/repos/saltstack/salt/labels/Pending%20Discussion","name":"Pending Discussion","color":"c7def8","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-10-24T21:21:45Z","updated_at":"2016-11-02T12:01:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/saltstack/salt/pulls/37200","html_url":"https://github.com/saltstack/salt/pull/37200","diff_url":"https://github.com/saltstack/salt/pull/37200.diff","patch_url":"https://github.com/saltstack/salt/pull/37200.patch"},"body":"### What does this PR do?\n\nAn external log file rotation tool, such as `logrotate` will not work\nwith an operating system such as Windows. From the Python documentation\nfor `WatchedFileHandler` (which is used for log files in Salt):\n\n\"This handler is not appropriate for use under Windows, because under\nWindows open log files cannot be moved or renamed - logging opens the\nfiles with exclusive locks - and so there is no need for such a handler.\nFurthermore, ST_INO is not supported under Windows; stat() always returns\nzero for this value.\"\n\nThis also describes the problem with why an external utility such as\n`logrotate` will not work for Windows, because files cannot be renamed\nwhile in use, unlike on other operating systems, such as Linux.\n\nDue to the above, the strategy for this change is to use the\n`RotatingFileHandler` logger (when log file rotation is enabled) and to\nallow only one process to do the file logging. Previously on Windows,\nthere was a file logger installed in the main process and another in the\nlogging listener process. This change changes the architecture in the\nfollowing way (on Windows only):\n- Added two new configuration options, `log_rotate_max_bytes` and\n  `log_rotate_backup_count`. They both default to 0. When\n  `log_rotate_max_bytes` is non-zero, the `RotatingFileHandler` will be\n  used for file logging instead of the `WatchedFileHandler`.\n- The only process that does file logging is the logging listener process\n  (if it exists)\n- When the logging listener process does not exist, only the main process\n  does file logging.\n- When the logging listener process exists, the main process will now set\n  up multiprocessing logging (which is the client to the logging listener).\n- Since the logging listener does logging for extended logging, console,\n  and log file logging, do not use these types of logging in the main process\n  when there is a logging listener.\n\nThere is one observed caveat: when the log file is in use, and it is time\nto rollover (rename the file), the rollover will fail. This has been\nobversed when salt-call is running and has the `minion` log file open\nfor its own logging uses while the salt-minion is trying to rollover.\nLuckily, it will recover and try to rollover again on the next log write,\nand if the file is no longer in use, it will succeed this time. Hence,\nhaving a log file open somewhere else will delay rollover until the file\nis closed.\n### Tests written?\n\nNo\n\nSigned-off-by: Sergey Kizunov sergey.kizunov@ni.com\n"},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/257845353","html_url":"https://github.com/saltstack/salt/pull/37200#issuecomment-257845353","issue_url":"https://api.github.com/repos/saltstack/salt/issues/37200","id":257845353,"user":{"login":"isbm","id":1073714,"avatar_url":"https://avatars.githubusercontent.com/u/1073714?v=3","gravatar_id":"","url":"https://api.github.com/users/isbm","html_url":"https://github.com/isbm","followers_url":"https://api.github.com/users/isbm/followers","following_url":"https://api.github.com/users/isbm/following{/other_user}","gists_url":"https://api.github.com/users/isbm/gists{/gist_id}","starred_url":"https://api.github.com/users/isbm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isbm/subscriptions","organizations_url":"https://api.github.com/users/isbm/orgs","repos_url":"https://api.github.com/users/isbm/repos","events_url":"https://api.github.com/users/isbm/events{/privacy}","received_events_url":"https://api.github.com/users/isbm/received_events","type":"User","site_admin":false},"created_at":"2016-11-02T12:01:40Z","updated_at":"2016-11-02T12:01:40Z","body":"P.S. Except the code comment I've made. :laughing: "}}
{"actor":{"display_login":"isbm"}}