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 -%} |
| 3 | {%- for log_handler_name, log_handler_attrs in _data.log_handlers.items() %} |
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 | |
| 9 | [loggers] |
| 10 | keys = root, {{ app_name }} |
| 11 | |
| 12 | [handlers] |
| 13 | keys = {{ log_handlers | join(", ") }} |
| 14 | |
| 15 | [formatters] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 16 | 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] | 17 | |
| 18 | [logger_root] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 19 | level = {{ _data.get('loggers', {}).get('root', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 20 | handlers = {{ log_handlers | join(", ") }} |
| 21 | |
| 22 | [logger_{{ app_name }}] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 23 | level = {{ _data.get('loggers', {}).get('{{ app_name }}', {}).get('level', 'INFO') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 24 | handlers = {{ log_handlers | join(", ") }} |
| 25 | qualname = {{ app_name }} |
| 26 | propagate = 0 |
| 27 | |
| 28 | [logger_amqp] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 29 | level = {{ _data.get('loggers', {}).get('amqp', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 30 | handlers = {{ log_handlers | join(", ") }} |
| 31 | qualname = amqp |
| 32 | |
| 33 | [logger_amqplib] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 34 | level = {{ _data.get('loggers', {}).get('amqplib', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 35 | handlers = {{ log_handlers | join(", ") }} |
| 36 | qualname = amqplib |
| 37 | |
| 38 | [logger_sqlalchemy] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 39 | level = {{ _data.get('loggers', {}).get('sqlalchemy', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 40 | handlers = {{ log_handlers | join(", ") }} |
| 41 | qualname = 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] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 47 | level = {{ _data.get('loggers', {}).get('boto', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 48 | handlers = {{ log_handlers | join(", ") }} |
| 49 | qualname = 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] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 55 | level = {{ _data.get('loggers', {}).get('suds', {}).get('level', 'INFO') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 56 | handlers = {{ log_handlers | join(", ") }} |
| 57 | qualname = suds |
| 58 | |
| 59 | [logger_eventletwsgi] |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 60 | level = {{ _data.get('loggers', {}).get('eventletwsgi', {}).get('level', 'WARNING') }} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 61 | handlers = {{ log_handlers | join(", ") }} |
| 62 | qualname = eventlet.wsgi.server |
| 63 | |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 64 | {% if _data.log_handlers.get('fluentd').get('enabled', False) -%} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 65 | [handler_fluentd] |
| 66 | class = fluent.handler.FluentHandler |
sgarbuz | eab0fe5 | 2018-09-10 18:55:36 +0300 | [diff] [blame^] | 67 | args = ("openstack.{{ service_name | replace("-", ".", 1) }}", 'localhost', 24224) |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 68 | formatter = fluentd |
| 69 | {%- endif %} |
| 70 | |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 71 | {% if _data.log_handlers.watchedfile.enabled -%} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 72 | [handler_watchedfile] |
| 73 | class = handlers.WatchedFileHandler |
sgarbuz | eab0fe5 | 2018-09-10 18:55:36 +0300 | [diff] [blame^] | 74 | args = ("/var/log/{{ app_name }}/{{ service_name }}.log",) |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 75 | formatter = context |
| 76 | {%- endif %} |
| 77 | |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 78 | {% if _data.log_handlers.get('ossyslog', {}).get('enabled', False) -%} |
| 79 | {%- set ossyslog_args = _data.log_handlers.ossyslog.get('args', {}) -%} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 80 | [handler_ossyslog] |
| 81 | class = 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. |
| 87 | args = ( 8 * handlers.SysLogHandler.{{ ossyslog_args.get('facility', 'LOG_USER') }}, ) |
| 88 | formatter = context |
| 89 | {%- endif %} |
| 90 | |
| 91 | [formatter_context] |
| 92 | class = oslo_log.formatters.ContextFormatter |
| 93 | |
| 94 | [formatter_default] |
| 95 | format = %(message)s |
| 96 | |
sgarbuz | f7cc76c | 2018-07-18 10:43:37 +0300 | [diff] [blame] | 97 | {% if _data.log_handlers.get('fluentd').get('enabled', False) -%} |
sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame] | 98 | [formatter_fluentd] |
| 99 | class = oslo_log.formatters.FluentFormatter |
| 100 | {%- endif %} |