[REM] builtin logrotate features

It's completely FUBAR when using workers[0] and properly
reimplementing it is not really worth the effort when logrotate(8) and
newsyslog(8) exist (or cyclog/multilog/cronolog if you subscribe to
the "logrotate and newsyslog are a design that should be consigned to
history" school of thought).

[0] https://stackoverflow.com/questions/34186774/why-doesnt-timedrotatingfilehandler-work-properly-and-how-to-solve-this-issuer

closes odoo/odoo#29073
This commit is contained in:
Xavier Morel
2018-11-27 14:05:03 +00:00
parent cb7589aaa5
commit 92d5a4bce5
3 changed files with 2 additions and 25 deletions
-13
View File
@@ -304,19 +304,6 @@ customize the amount of logging output
<https://docs.python.org/2/library/logging.handlers.html#watchedfilehandler>`_
and will automatically be reopened when replaced
.. option:: --logrotate
enables `log rotation <https://docs.python.org/2/library/logging.handlers.html#timedrotatingfilehandler>`_
daily, keeping 30 backups. Log rotation frequency and number of backups is
not configurable.
.. danger::
Built-in log rotation is not reliable in multi-workers scenarios
and may incur significant data loss. It is *strongly recommended* to
use an external log rotation utility or use system loggers (--syslog)
instead.
.. option:: --syslog
logs to the system's event logger: `syslog on unices <https://docs.python.org/2/library/logging.handlers.html#sysloghandler>`_
+1 -10
View File
@@ -156,16 +156,7 @@ def init_logger():
dirname = os.path.dirname(logf)
if dirname and not os.path.isdir(dirname):
os.makedirs(dirname)
if tools.config['logrotate'] is not False:
if tools.config['workers'] and tools.config['workers'] > 1:
# TODO: fallback to regular file logging in master for safe(r) defaults?
#
# Doing so here would be a good idea but also might break
# situations were people do log-shipping of rotated data?
_logger.warn("WARNING: built-in log rotation is not reliable in multi-worker scenarios and may incur significant data loss. "
"It is strongly recommended to use an external log rotation utility or use system loggers (--syslog) instead.")
handler = logging.handlers.TimedRotatingFileHandler(filename=logf, when='D', interval=1, backupCount=30)
elif os.name == 'posix':
if os.name == 'posix':
handler = logging.handlers.WatchedFileHandler(logf)
else:
handler = logging.FileHandler(logf)
+1 -2
View File
@@ -167,7 +167,6 @@ class configmanager(object):
# Logging Group
group = optparse.OptionGroup(parser, "Logging Configuration")
group.add_option("--logfile", dest="logfile", help="file where the server log will be stored")
group.add_option("--logrotate", dest="logrotate", action="store_true", my_default=False, help="enable logfile rotation")
group.add_option("--syslog", action="store_true", dest="syslog", my_default=False, help="Send the log to the syslog server")
group.add_option('--log-handler', action="append", default=[], my_default=DEFAULT_LOG_HANDLER, metavar="PREFIX:LEVEL", help='setup a handler at LEVEL for a given PREFIX. An empty PREFIX indicates the root logger. This option can be repeated. Example: "odoo.orm:DEBUG" or "werkzeug:CRITICAL" (default: ":INFO")')
group.add_option('--log-request', action="append_const", dest="log_handler", const="odoo.http.rpc.request:DEBUG", help='shortcut for --log-handler=odoo.http.rpc.request:DEBUG')
@@ -429,7 +428,7 @@ class configmanager(object):
keys = [
'language', 'translate_out', 'translate_in', 'overwrite_existing_translations',
'dev_mode', 'shell_interface', 'smtp_ssl', 'load_language',
'stop_after_init', 'logrotate', 'without_demo', 'http_enable', 'syslog',
'stop_after_init', 'without_demo', 'http_enable', 'syslog',
'list_db', 'proxy_mode',
'test_file', 'test_tags',
'osv_memory_count_limit', 'osv_memory_age_limit', 'max_cron_threads', 'unaccent',