blob: 6c7998239985d4723b451d5908f478bc16a89c78 [file] [log] [blame]
sgarbuz2d8f8052018-07-13 13:04:54 +03001{%- set log_handlers = [] -%}
2{%- set app_name = _data.logging.app_name -%}
3{%- for log_handler_name, log_handler_attrs in _data.logging.log_handlers.items() %}
4 {%- if log_handler_attrs.get('enabled', False) %}
5 {%- do log_handlers.append(log_handler_name) -%}
6 {%- endif %}
7{%- endfor %}
8
9[loggers]
10keys = root, {{ app_name }}
11
12[handlers]
13keys = {{ log_handlers | join(", ") }}
14
15[formatters]
16keys = context, default{% if _data.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}, fluentd{% endif %}
17
18[logger_root]
19level = {{ _data.logging.get('loggers', {}).get('root', {}).get('level', 'WARNING') }}
20handlers = {{ log_handlers | join(", ") }}
21
22[logger_{{ app_name }}]
23level = {{ _data.logging.get('loggers', {}).get('{{ app_name }}', {}).get('level', 'INFO') }}
24handlers = {{ log_handlers | join(", ") }}
25qualname = {{ app_name }}
26propagate = 0
27
28[logger_amqp]
29level = {{ _data.logging.get('loggers', {}).get('amqp', {}).get('level', 'WARNING') }}
30handlers = {{ log_handlers | join(", ") }}
31qualname = amqp
32
33[logger_amqplib]
34level = {{ _data.logging.get('loggers', {}).get('amqplib', {}).get('level', 'WARNING') }}
35handlers = {{ log_handlers | join(", ") }}
36qualname = amqplib
37
38[logger_sqlalchemy]
39level = {{ _data.logging.get('loggers', {}).get('sqlalchemy', {}).get('level', 'WARNING') }}
40handlers = {{ log_handlers | join(", ") }}
41qualname = sqlalchemy
42# "level = INFO" logs SQL queries.
43# "level = DEBUG" logs SQL queries and results.
44# "level = WARNING" logs neither. (Recommended for production systems.)
45
46[logger_boto]
47level = {{ _data.logging.get('loggers', {}).get('boto', {}).get('level', 'WARNING') }}
48handlers = {{ log_handlers | join(", ") }}
49qualname = boto
50
51# NOTE(mikal): suds is used by the vmware driver, removing this will
52# cause many extraneous log lines for their tempest runs. Refer to
53# https://review.openstack.org/#/c/219225/ for details.
54[logger_suds]
55level = {{ _data.logging.get('loggers', {}).get('suds', {}).get('level', 'INFO') }}
56handlers = {{ log_handlers | join(", ") }}
57qualname = suds
58
59[logger_eventletwsgi]
60level = {{ _data.logging.get('loggers', {}).get('eventletwsgi', {}).get('level', 'WARNING') }}
61handlers = {{ log_handlers | join(", ") }}
62qualname = eventlet.wsgi.server
63
64{% if _data.logging.log_handlers.get('fluentd').get('enabled', False) -%}
65[handler_fluentd]
66class = fluent.handler.FluentHandler
67args = ('openstack.{{ service_name | replace("-", ".", 1) }}', 'localhost', 24224)
68formatter = fluentd
69{%- endif %}
70
71{% if _data.logging.log_handlers.watchedfile.enabled -%}
72[handler_watchedfile]
73class = handlers.WatchedFileHandler
74args = ('/var/log/{{ app_name }}/{{ service_name }}.log',)
75formatter = context
76{%- endif %}
77
78{% if _data.logging.log_handlers.get('ossyslog', {}).get('enabled', False) -%}
79{%- set ossyslog_args = _data.logging.log_handlers.ossyslog.get('args', {}) -%}
80[handler_ossyslog]
81class = oslo_log.handlers.OSSysLogHandler
82# the OSSysLogHandler uses 'syslog' lib, where the LOG_* facilities are already *8
83# but in the context where the args are evaluated we have access only to Python's
84# handlers.SysLogHandler.LOG_* constants that _ARE_NOT_ multiplied by 8.
85# To not have a completely magic single int in the rendered template,
86# we multiply it here.
87args = ( 8 * handlers.SysLogHandler.{{ ossyslog_args.get('facility', 'LOG_USER') }}, )
88formatter = context
89{%- endif %}
90
91[formatter_context]
92class = oslo_log.formatters.ContextFormatter
93
94[formatter_default]
95format = %(message)s
96
97{% if _data.logging.log_handlers.get('fluentd').get('enabled', False) -%}
98[formatter_fluentd]
99class = oslo_log.formatters.FluentFormatter
100{%- endif %}