blob: ecbc0e870f8168f528327603476487ee1ab71928 [file] [log] [blame]
{%- set log_handlers = [] -%}
{%- set app_name = _data.app_name -%}
{%- for log_handler_name, log_handler_attrs in _data.get('log_handlers', {}).iteritems() %}
{%- if log_handler_attrs.get('enabled', False) %}
{%- do log_handlers.append(log_handler_name) -%}
{%- endif %}
{%- endfor %}
{%- set loggers = ["root", app_name] -%}
{%- for _logger_name, _logger_attrs in _data.get('loggers', {}).iteritems() %}
{%- if _logger_attrs.get('enabled', False) and _logger_name not in loggers %}
{%- do loggers.append(_logger_name) -%}
{%- endif %}
{%- endfor %}
[loggers]
keys = {{ loggers | join(", ") }}
[handlers]
keys = {{ log_handlers | join(", ") }}
[formatters]
keys = context, default{% if _data.log_handlers.get('fluentd', {}).get('enabled', False) %}, fluentd{% endif %}
[logger_root]
level = {{ _data.get('loggers', {}).get('root', {}).get('level', 'WARNING') }}
handlers = {{ log_handlers | join(", ") }}
[logger_{{ app_name }}]
level = {{ _data.get('loggers', {}).get(app_name, {}).get('level', 'INFO') }}
handlers = {{ log_handlers | join(", ") }}
qualname = {{ app_name }}
propagate = 0
[logger_amqp]
level = {{ _data.get('loggers', {}).get('amqp', {}).get('level', 'WARNING') }}
handlers = {{ log_handlers | join(", ") }}
qualname = amqp
[logger_amqplib]
level = {{ _data.get('loggers', {}).get('amqplib', {}).get('level', 'WARNING') }}
handlers = {{ log_handlers | join(", ") }}
qualname = amqplib
[logger_sqlalchemy]
level = {{ _data.get('loggers', {}).get('sqlalchemy', {}).get('level', 'WARNING') }}
handlers = {{ log_handlers | join(", ") }}
qualname = sqlalchemy
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARNING" logs neither. (Recommended for production systems.)
[logger_boto]
level = {{ _data.get('loggers', {}).get('boto', {}).get('level', 'WARNING') }}
handlers = {{ log_handlers | join(", ") }}
qualname = boto
# NOTE(mikal): suds is used by the vmware driver, removing this will
# cause many extraneous log lines for their tempest runs. Refer to
# https://review.openstack.org/#/c/219225/ for details.
[logger_suds]
level = {{ _data.get('loggers', {}).get('suds', {}).get('level', 'INFO') }}
handlers = {{ log_handlers | join(", ") }}
qualname = suds
[logger_eventletwsgi]
level = {{ _data.get('loggers', {}).get('eventletwsgi', {}).get('level', 'WARNING') }}
handlers = {{ log_handlers | join(", ") }}
qualname = eventlet.wsgi.server
{% if _data.log_handlers.get('fluentd').get('enabled', False) -%}
[handler_fluentd]
class = fluent.handler.FluentHandler
args = ("openstack.{{ service_name | replace("-", ".", 1) }}", 'localhost', 24224)
formatter = fluentd
{%- endif %}
{% if _data.log_handlers.watchedfile.enabled -%}
[handler_watchedfile]
class = handlers.WatchedFileHandler
args = ("/var/log/{{ app_name }}/{{ service_name }}.log",)
formatter = context
{%- endif %}
{% if _data.log_handlers.get('ossyslog', {}).get('enabled', False) -%}
{%- set ossyslog_args = _data.log_handlers.ossyslog.get('args', {}) -%}
[handler_ossyslog]
class = oslo_log.handlers.OSSysLogHandler
# the OSSysLogHandler uses 'syslog' lib, where the LOG_* facilities are already *8
# but in the context where the args are evaluated we have access only to Python's
# handlers.SysLogHandler.LOG_* constants that _ARE_NOT_ multiplied by 8.
# To not have a completely magic single int in the rendered template,
# we multiply it here.
args = ( 8 * handlers.SysLogHandler.{{ ossyslog_args.get('facility', 'LOG_USER') }}, )
formatter = context
{%- endif %}
[formatter_context]
class = oslo_log.formatters.ContextFormatter
[formatter_default]
format = %(message)s
{% if _data.log_handlers.get('fluentd').get('enabled', False) -%}
[formatter_fluentd]
class = oslo_log.formatters.FluentFormatter
{%- endif %}