Glance add ability to use global logging.conf
Add ability to use global logging.conf template which can be
used in all openstack components which support oslo.log
Change-Id: I6b2d388c38f10d708e40ead870cea8566b5a53e6
Related-Prod: PROD-21353
diff --git a/glance/files/logging.conf b/glance/files/logging.conf
deleted file mode 100644
index 724c0a2..0000000
--- a/glance/files/logging.conf
+++ /dev/null
@@ -1,90 +0,0 @@
-{%- set log_handlers = [] -%}
-{%- for log_handler_name, log_handler_attrs in values.logging.log_handlers.items() %}
- {%- if log_handler_attrs.get('enabled', False) %}
- {%- do log_handlers.append(log_handler_name) -%}
- {%- endif %}
-{%- endfor %}
-[loggers]
-keys = root, glance, eventletwsgi
-
-[handlers]
-keys = {{ log_handlers | join(", ") }}
-
-[formatters]
-keys = context, default{% if values.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}, fluentd{% endif %}
-
-[logger_root]
-level = WARNING
-handlers = {{ log_handlers | join(", ") }}
-
-[logger_glance]
-level = INFO
-handlers = {{ log_handlers | join(", ") }}
-qualname = glance
-propagate = 0
-
-[logger_amqplib]
-level = WARNING
-handlers = {{ log_handlers | join(", ") }}
-qualname = amqplib
-
-[logger_sqlalchemy]
-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 = WARNING
-handlers = {{ log_handlers | join(", ") }}
-qualname = boto
-
-[logger_suds]
-level = INFO
-handlers = {{ log_handlers | join(", ") }}
-qualname = suds
-
-[logger_eventletwsgi]
-level = INFO
-handlers = {{ log_handlers | join(", ") }}
-qualname = eventlet.wsgi.server
-
-{%- if values.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
-[handler_fluentd]
-class = fluent.handler.FluentHandler
-args = ('openstack.{{ service_name | replace("-", ".") }}', 'localhost', 24224)
-formatter = fluentd
-{%- endif %}
-
-{%- if values.logging.log_handlers.watchedfile.enabled %}
-[handler_watchedfile]
-class = handlers.WatchedFileHandler
-args = ('/var/log/glance/{{ service_name }}.log',)
-formatter = context
-{%- endif %}
-
-{% if values.logging.log_handlers.get('ossyslog', {}).get('enabled', False) -%}
-{%- set ossyslog_args = values.logging.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 values.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
-[formatter_fluentd]
-class = oslo_log.formatters.FluentFormatter
-{%- endif %}
diff --git a/glance/map.jinja b/glance/map.jinja
index 3303071..400d035 100644
--- a/glance/map.jinja
+++ b/glance/map.jinja
@@ -24,7 +24,7 @@
'policy_file': '/etc/glance/policy.json'
},
'logging': {
- 'log_file': '/var/log/glance/api.log',
+ 'app_name': 'glance',
'log_appender': false,
'log_handlers': {
'watchedfile': {
@@ -50,7 +50,7 @@
'policy_file': '/etc/glance/policy.json'
},
'logging': {
- 'log_file': '/var/log/glance/api.log',
+ 'app_name': 'glance',
'log_appender': false,
'log_handlers': {
'watchedfile': {
diff --git a/glance/server.sls b/glance/server.sls
index 3eccfc7..7618c72 100644
--- a/glance/server.sls
+++ b/glance/server.sls
@@ -145,18 +145,36 @@
- name: python-fluent-logger
{%- endif %}
+glance_general_logging_conf:
+ file.managed:
+ - name: /etc/glance/logging.conf
+ - source: salt://oslo_templates/files/logging/_logging.conf
+ - template: jinja
+ - user: glance
+ - group: glance
+ - defaults:
+ service_name: glance
+ _data: {{ server.logging }}
+ - require:
+ - pkg: glance_packages
+{%- if server.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
+ - pkg: glance_fluentd_logger_package
+{%- endif %}
+ - watch_in:
+ - service: glance_services
+
{% for service_name in glance_services_list %}
{{ service_name }}_logging_conf:
file.managed:
- name: /etc/glance/logging/logging-{{ service_name }}.conf
- - source: salt://glance/files/logging.conf
+ - source: salt://oslo_templates/files/logging/_logging.conf
- template: jinja
- makedirs: True
- user: glance
- group: glance
- defaults:
service_name: {{ service_name }}
- values: {{ server }}
+ _data: {{ server.logging }}
- require:
- pkg: glance_packages
{%- if glance_glare_available %}