blob: ecbc0e870f8168f528327603476487ee1ab71928 [file] [log] [blame]
sgarbuz2d8f8052018-07-13 13:04:54 +03001{%- set log_handlers = [] -%}
sgarbuzf7cc76c2018-07-18 10:43:37 +03002{%- set app_name = _data.app_name -%}
Ksawery Dziekoński738d96b2020-03-02 13:00:38 +01003{%- for log_handler_name, log_handler_attrs in _data.get('log_handlers', {}).iteritems() %}
sgarbuz2d8f8052018-07-13 13:04:54 +03004 {%- if log_handler_attrs.get('enabled', False) %}
5 {%- do log_handlers.append(log_handler_name) -%}
6 {%- endif %}
7{%- endfor %}
8
Ksawery Dziekoński738d96b2020-03-02 13:00:38 +01009{%- set loggers = ["root", app_name] -%}
10{%- for _logger_name, _logger_attrs in _data.get('loggers', {}).iteritems() %}
11 {%- if _logger_attrs.get('enabled', False) and _logger_name not in loggers %}
12 {%- do loggers.append(_logger_name) -%}
13 {%- endif %}
14{%- endfor %}
15
sgarbuz2d8f8052018-07-13 13:04:54 +030016[loggers]
Ksawery Dziekoński738d96b2020-03-02 13:00:38 +010017keys = {{ loggers | join(", ") }}
sgarbuz2d8f8052018-07-13 13:04:54 +030018
19[handlers]
20keys = {{ log_handlers | join(", ") }}
21
22[formatters]
sgarbuzf7cc76c2018-07-18 10:43:37 +030023keys = context, default{% if _data.log_handlers.get('fluentd', {}).get('enabled', False) %}, fluentd{% endif %}
sgarbuz2d8f8052018-07-13 13:04:54 +030024
25[logger_root]
Oleksii Molchanov2e66f842020-01-21 15:17:41 +020026level = {{ _data.get('loggers', {}).get('root', {}).get('level', 'WARNING') }}
sgarbuz2d8f8052018-07-13 13:04:54 +030027handlers = {{ log_handlers | join(", ") }}
28
29[logger_{{ app_name }}]
Andrey Bubyrb6b66a72018-12-30 20:55:49 +020030level = {{ _data.get('loggers', {}).get(app_name, {}).get('level', 'INFO') }}
sgarbuz2d8f8052018-07-13 13:04:54 +030031handlers = {{ log_handlers | join(", ") }}
32qualname = {{ app_name }}
33propagate = 0
34
35[logger_amqp]
sgarbuzf7cc76c2018-07-18 10:43:37 +030036level = {{ _data.get('loggers', {}).get('amqp', {}).get('level', 'WARNING') }}
sgarbuz2d8f8052018-07-13 13:04:54 +030037handlers = {{ log_handlers | join(", ") }}
38qualname = amqp
39
40[logger_amqplib]
sgarbuzf7cc76c2018-07-18 10:43:37 +030041level = {{ _data.get('loggers', {}).get('amqplib', {}).get('level', 'WARNING') }}
sgarbuz2d8f8052018-07-13 13:04:54 +030042handlers = {{ log_handlers | join(", ") }}
43qualname = amqplib
44
45[logger_sqlalchemy]
sgarbuzf7cc76c2018-07-18 10:43:37 +030046level = {{ _data.get('loggers', {}).get('sqlalchemy', {}).get('level', 'WARNING') }}
sgarbuz2d8f8052018-07-13 13:04:54 +030047handlers = {{ log_handlers | join(", ") }}
48qualname = sqlalchemy
49# "level = INFO" logs SQL queries.
50# "level = DEBUG" logs SQL queries and results.
51# "level = WARNING" logs neither. (Recommended for production systems.)
52
53[logger_boto]
sgarbuzf7cc76c2018-07-18 10:43:37 +030054level = {{ _data.get('loggers', {}).get('boto', {}).get('level', 'WARNING') }}
sgarbuz2d8f8052018-07-13 13:04:54 +030055handlers = {{ log_handlers | join(", ") }}
56qualname = boto
57
58# NOTE(mikal): suds is used by the vmware driver, removing this will
59# cause many extraneous log lines for their tempest runs. Refer to
60# https://review.openstack.org/#/c/219225/ for details.
61[logger_suds]
sgarbuzf7cc76c2018-07-18 10:43:37 +030062level = {{ _data.get('loggers', {}).get('suds', {}).get('level', 'INFO') }}
sgarbuz2d8f8052018-07-13 13:04:54 +030063handlers = {{ log_handlers | join(", ") }}
64qualname = suds
65
66[logger_eventletwsgi]
sgarbuzf7cc76c2018-07-18 10:43:37 +030067level = {{ _data.get('loggers', {}).get('eventletwsgi', {}).get('level', 'WARNING') }}
sgarbuz2d8f8052018-07-13 13:04:54 +030068handlers = {{ log_handlers | join(", ") }}
69qualname = eventlet.wsgi.server
70
sgarbuzf7cc76c2018-07-18 10:43:37 +030071{% if _data.log_handlers.get('fluentd').get('enabled', False) -%}
sgarbuz2d8f8052018-07-13 13:04:54 +030072[handler_fluentd]
73class = fluent.handler.FluentHandler
sgarbuzeab0fe52018-09-10 18:55:36 +030074args = ("openstack.{{ service_name | replace("-", ".", 1) }}", 'localhost', 24224)
sgarbuz2d8f8052018-07-13 13:04:54 +030075formatter = fluentd
76{%- endif %}
77
sgarbuzf7cc76c2018-07-18 10:43:37 +030078{% if _data.log_handlers.watchedfile.enabled -%}
sgarbuz2d8f8052018-07-13 13:04:54 +030079[handler_watchedfile]
80class = handlers.WatchedFileHandler
sgarbuzeab0fe52018-09-10 18:55:36 +030081args = ("/var/log/{{ app_name }}/{{ service_name }}.log",)
sgarbuz2d8f8052018-07-13 13:04:54 +030082formatter = context
83{%- endif %}
84
sgarbuzf7cc76c2018-07-18 10:43:37 +030085{% if _data.log_handlers.get('ossyslog', {}).get('enabled', False) -%}
86{%- set ossyslog_args = _data.log_handlers.ossyslog.get('args', {}) -%}
sgarbuz2d8f8052018-07-13 13:04:54 +030087[handler_ossyslog]
88class = oslo_log.handlers.OSSysLogHandler
89# the OSSysLogHandler uses 'syslog' lib, where the LOG_* facilities are already *8
90# but in the context where the args are evaluated we have access only to Python's
91# handlers.SysLogHandler.LOG_* constants that _ARE_NOT_ multiplied by 8.
92# To not have a completely magic single int in the rendered template,
93# we multiply it here.
94args = ( 8 * handlers.SysLogHandler.{{ ossyslog_args.get('facility', 'LOG_USER') }}, )
95formatter = context
96{%- endif %}
97
98[formatter_context]
99class = oslo_log.formatters.ContextFormatter
100
101[formatter_default]
102format = %(message)s
103
sgarbuzf7cc76c2018-07-18 10:43:37 +0300104{% if _data.log_handlers.get('fluentd').get('enabled', False) -%}
sgarbuz2d8f8052018-07-13 13:04:54 +0300105[formatter_fluentd]
106class = oslo_log.formatters.FluentFormatter
107{%- endif %}