sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 1 | {%- set log_handlers = [] -%} |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 2 | {%- set app_name = _data.app_name -%} |
Ksawery Dziekoński | 738d96b | 2020-03-02 13:00:38 +0100 | [diff] [blame] | 3 | {%- for log_handler_name, log_handler_attrs in _data.get('log_handlers', {}).iteritems() %} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 4 | {%- if log_handler_attrs.get('enabled', False) %} |
| 5 | {%- do log_handlers.append(log_handler_name) -%} |
| 6 | {%- endif %} |
| 7 | {%- endfor %} |
| 8 | |
Ksawery Dziekoński | 738d96b | 2020-03-02 13:00:38 +0100 | [diff] [blame] | 9 | {%- 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 | |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 16 | [loggers] |
Ksawery Dziekoński | 738d96b | 2020-03-02 13:00:38 +0100 | [diff] [blame] | 17 | keys = {{ loggers | join(", ") }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 18 | |
| 19 | [handlers] |
| 20 | keys = {{ log_handlers | join(", ") }} |
| 21 | |
| 22 | [formatters] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 23 | keys = context, default{% if _data.log_handlers.get('fluentd', {}).get('enabled', False) %}, fluentd{% endif %} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 24 | |
| 25 | [logger_root] |
Oleksii Molchanov | 2e66f84 | 2020-01-21 15:17:41 +0200 | [diff] [blame] | 26 | level = {{ _data.get('loggers', {}).get('root', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 27 | handlers = {{ log_handlers | join(", ") }} |
| 28 | |
| 29 | [logger_{{ app_name }}] |
Andrey Bubyr | b6b66a7 | 2018-12-30 20:55:49 +0200 | [diff] [blame] | 30 | level = {{ _data.get('loggers', {}).get(app_name, {}).get('level', 'INFO') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 31 | handlers = {{ log_handlers | join(", ") }} |
| 32 | qualname = {{ app_name }} |
| 33 | propagate = 0 |
| 34 | |
| 35 | [logger_amqp] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 36 | level = {{ _data.get('loggers', {}).get('amqp', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 37 | handlers = {{ log_handlers | join(", ") }} |
| 38 | qualname = amqp |
| 39 | |
| 40 | [logger_amqplib] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 41 | level = {{ _data.get('loggers', {}).get('amqplib', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 42 | handlers = {{ log_handlers | join(", ") }} |
| 43 | qualname = amqplib |
| 44 | |
| 45 | [logger_sqlalchemy] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 46 | level = {{ _data.get('loggers', {}).get('sqlalchemy', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 47 | handlers = {{ log_handlers | join(", ") }} |
| 48 | qualname = 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] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 54 | level = {{ _data.get('loggers', {}).get('boto', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 55 | handlers = {{ log_handlers | join(", ") }} |
| 56 | qualname = 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] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 62 | level = {{ _data.get('loggers', {}).get('suds', {}).get('level', 'INFO') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 63 | handlers = {{ log_handlers | join(", ") }} |
| 64 | qualname = suds |
| 65 | |
| 66 | [logger_eventletwsgi] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 67 | level = {{ _data.get('loggers', {}).get('eventletwsgi', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 68 | handlers = {{ log_handlers | join(", ") }} |
| 69 | qualname = eventlet.wsgi.server |
| 70 | |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 71 | {% if _data.log_handlers.get('fluentd').get('enabled', False) -%} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 72 | [handler_fluentd] |
| 73 | class = fluent.handler.FluentHandler |
sgarbuz | eab0fe5 | 2018-09-10 18:55:36 +0300 | [diff] [blame] | 74 | args = ("openstack.{{ service_name | replace("-", ".", 1) }}", 'localhost', 24224) |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 75 | formatter = fluentd |
| 76 | {%- endif %} |
| 77 | |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 78 | {% if _data.log_handlers.watchedfile.enabled -%} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 79 | [handler_watchedfile] |
| 80 | class = handlers.WatchedFileHandler |
sgarbuz | eab0fe5 | 2018-09-10 18:55:36 +0300 | [diff] [blame] | 81 | args = ("/var/log/{{ app_name }}/{{ service_name }}.log",) |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 82 | formatter = context |
| 83 | {%- endif %} |
| 84 | |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 85 | {% if _data.log_handlers.get('ossyslog', {}).get('enabled', False) -%} |
| 86 | {%- set ossyslog_args = _data.log_handlers.ossyslog.get('args', {}) -%} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 87 | [handler_ossyslog] |
| 88 | class = 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. |
| 94 | args = ( 8 * handlers.SysLogHandler.{{ ossyslog_args.get('facility', 'LOG_USER') }}, ) |
| 95 | formatter = context |
| 96 | {%- endif %} |
| 97 | |
| 98 | [formatter_context] |
| 99 | class = oslo_log.formatters.ContextFormatter |
| 100 | |
| 101 | [formatter_default] |
| 102 | format = %(message)s |
| 103 | |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 104 | {% if _data.log_handlers.get('fluentd').get('enabled', False) -%} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 105 | [formatter_fluentd] |
| 106 | class = oslo_log.formatters.FluentFormatter |
| 107 | {%- endif %} |