Use WatchedFileHandler to avoid copytruncate.

Python logging has a WatchedFileHandler which will do the correct thing
for logrotate when copytruncate is not used. Do this to avoid having
multiple copies of the same log in place. Also, this should avoid a race
where log data is lost between copying and truncating done by logrotate.

Change-Id: Idbbc7869004a03b8f19cfbd81ad07f5584ce1964
This commit is contained in:
Clark Boylan 2014-05-27 15:03:38 -07:00
parent 77c193f23d
commit ddb23eeb7b
5 changed files with 5 additions and 10 deletions

View File

@ -24,7 +24,7 @@ args=(sys.stdout,)
[handler_normal] [handler_normal]
level=WARNING level=WARNING
class=logging.FileHandler class=logging.handlers.WatchedFileHandler
formatter=simple formatter=simple
args=('/var/log/zuul/gearman-server.log',) args=('/var/log/zuul/gearman-server.log',)

View File

@ -34,13 +34,13 @@ args=(sys.stdout,)
[handler_debug] [handler_debug]
level=DEBUG level=DEBUG
class=logging.FileHandler class=logging.handlers.WatchedFileHandler
formatter=simple formatter=simple
args=('/var/log/zuul/debug.log',) args=('/var/log/zuul/debug.log',)
[handler_normal] [handler_normal]
level=INFO level=INFO
class=logging.FileHandler class=logging.handlers.WatchedFileHandler
formatter=simple formatter=simple
args=('/var/log/zuul/zuul.log',) args=('/var/log/zuul/zuul.log',)

View File

@ -34,13 +34,13 @@ args=(sys.stdout,)
[handler_debug] [handler_debug]
level=DEBUG level=DEBUG
class=logging.FileHandler class=logging.handlers.WatchedFileHandler
formatter=simple formatter=simple
args=('/var/log/zuul/merger-debug.log',) args=('/var/log/zuul/merger-debug.log',)
[handler_normal] [handler_normal]
level=INFO level=INFO
class=logging.FileHandler class=logging.handlers.WatchedFileHandler
formatter=simple formatter=simple
args=('/var/log/zuul/merger.log',) args=('/var/log/zuul/merger.log',)

View File

@ -39,7 +39,6 @@ class zuul::merger (
log => '/var/log/zuul/merger.log', log => '/var/log/zuul/merger.log',
options => [ options => [
'compress', 'compress',
'copytruncate',
'missingok', 'missingok',
'rotate 30', 'rotate 30',
'daily', 'daily',
@ -51,7 +50,6 @@ class zuul::merger (
log => '/var/log/zuul/merger-debug.log', log => '/var/log/zuul/merger-debug.log',
options => [ options => [
'compress', 'compress',
'copytruncate',
'missingok', 'missingok',
'rotate 30', 'rotate 30',
'daily', 'daily',

View File

@ -35,7 +35,6 @@ class zuul::server (
log => '/var/log/zuul/zuul.log', log => '/var/log/zuul/zuul.log',
options => [ options => [
'compress', 'compress',
'copytruncate',
'missingok', 'missingok',
'rotate 30', 'rotate 30',
'daily', 'daily',
@ -47,7 +46,6 @@ class zuul::server (
log => '/var/log/zuul/debug.log', log => '/var/log/zuul/debug.log',
options => [ options => [
'compress', 'compress',
'copytruncate',
'missingok', 'missingok',
'rotate 30', 'rotate 30',
'daily', 'daily',
@ -59,7 +57,6 @@ class zuul::server (
log => '/var/log/zuul/gearman-server.log', log => '/var/log/zuul/gearman-server.log',
options => [ options => [
'compress', 'compress',
'copytruncate',
'missingok', 'missingok',
'rotate 7', 'rotate 7',
'daily', 'daily',