sgarbuz | 2d8f805 | 2018-07-13 13:04:54 +0300 | [diff] [blame^] | 1 | {%- 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] |
| 10 | keys = root, {{ app_name }} |
| 11 | |
| 12 | [handlers] |
| 13 | keys = {{ log_handlers | join(", ") }} |
| 14 | |
| 15 | [formatters] |
| 16 | keys = context, default{% if _data.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}, fluentd{% endif %} |
| 17 | |
| 18 | [logger_root] |
| 19 | level = {{ _data.logging.get('loggers', {}).get('root', {}).get('level', 'WARNING') }} |
| 20 | handlers = {{ log_handlers | join(", ") }} |
| 21 | |
| 22 | [logger_{{ app_name }}] |
| 23 | level = {{ _data.logging.get('loggers', {}).get('{{ app_name }}', {}).get('level', 'INFO') }} |
| 24 | handlers = {{ log_handlers | join(", ") }} |
| 25 | qualname = {{ app_name }} |
| 26 | propagate = 0 |
| 27 | |
| 28 | [logger_amqp] |
| 29 | level = {{ _data.logging.get('loggers', {}).get('amqp', {}).get('level', 'WARNING') }} |
| 30 | handlers = {{ log_handlers | join(", ") }} |
| 31 | qualname = amqp |
| 32 | |
| 33 | [logger_amqplib] |
| 34 | level = {{ _data.logging.get('loggers', {}).get('amqplib', {}).get('level', 'WARNING') }} |
| 35 | handlers = {{ log_handlers | join(", ") }} |
| 36 | qualname = amqplib |
| 37 | |
| 38 | [logger_sqlalchemy] |
| 39 | level = {{ _data.logging.get('loggers', {}).get('sqlalchemy', {}).get('level', 'WARNING') }} |
| 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] |
| 47 | level = {{ _data.logging.get('loggers', {}).get('boto', {}).get('level', 'WARNING') }} |
| 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] |
| 55 | level = {{ _data.logging.get('loggers', {}).get('suds', {}).get('level', 'INFO') }} |
| 56 | handlers = {{ log_handlers | join(", ") }} |
| 57 | qualname = suds |
| 58 | |
| 59 | [logger_eventletwsgi] |
| 60 | level = {{ _data.logging.get('loggers', {}).get('eventletwsgi', {}).get('level', 'WARNING') }} |
| 61 | handlers = {{ log_handlers | join(", ") }} |
| 62 | qualname = eventlet.wsgi.server |
| 63 | |
| 64 | {% if _data.logging.log_handlers.get('fluentd').get('enabled', False) -%} |
| 65 | [handler_fluentd] |
| 66 | class = fluent.handler.FluentHandler |
| 67 | args = ('openstack.{{ service_name | replace("-", ".", 1) }}', 'localhost', 24224) |
| 68 | formatter = fluentd |
| 69 | {%- endif %} |
| 70 | |
| 71 | {% if _data.logging.log_handlers.watchedfile.enabled -%} |
| 72 | [handler_watchedfile] |
| 73 | class = handlers.WatchedFileHandler |
| 74 | args = ('/var/log/{{ app_name }}/{{ service_name }}.log',) |
| 75 | formatter = 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] |
| 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 | |
| 97 | {% if _data.logging.log_handlers.get('fluentd').get('enabled', False) -%} |
| 98 | [formatter_fluentd] |
| 99 | class = oslo_log.formatters.FluentFormatter |
| 100 | {%- endif %} |