Add support of OSSysLogHandler logging handler

Change-Id: I56cf1e9dfc536a5dd8b34c1228cec5c24e97c9f8
diff --git a/README.rst b/README.rst
index 1d39d55..6e4d1cc 100644
--- a/README.rst
+++ b/README.rst
@@ -706,8 +706,9 @@
 That is possible to enable per-binary logging.conf with new variables:
   * openstack_log_appender - set it to true to enable log_config_append for all OpenStack services;
   * openstack_fluentd_handler_enabled - set to true to enable FluentHandler for all Openstack services.
+  * openstack_ossyslog_handler_enabled - set to true to enable OSSysLogHandler for all Openstack services.
 
-Only WatchedFileHandler and FluentHandler are available.
+Only WatchedFileHandler, OSSysLogHandler and FluentHandler are available.
 
 Also it is possible to configure this with pillar:
 
@@ -722,6 +723,8 @@
             enabled: true
           fluentd:
             enabled: true
+          ossyslog:
+            enabled: true
 
 Usage
 =====
diff --git a/keystone/files/logging.conf b/keystone/files/logging.conf
index c079968..9bd6435 100644
--- a/keystone/files/logging.conf
+++ b/keystone/files/logging.conf
@@ -11,7 +11,7 @@
 keys = {{ log_handlers | join(", ") }}
 
 [formatters]
-keys = context, default, fluentd
+keys = context, default{% if values.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}, fluentd{% endif %}
 
 [logger_root]
 level = WARNING
@@ -51,6 +51,14 @@
 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
+args = ( handlers.SysLogHandler.{{ ossyslog_args.get('facility', 'LOG_USER') }}, )
+formatter = context
+{%- endif %}
+
 [formatter_context]
 class = oslo_log.formatters.ContextFormatter
 
diff --git a/metadata/service/server/cluster.yml b/metadata/service/server/cluster.yml
index 1088421..4be3b3d 100644
--- a/metadata/service/server/cluster.yml
+++ b/metadata/service/server/cluster.yml
@@ -6,6 +6,7 @@
   _param:
     openstack_log_appender: false
     openstack_fluentd_handler_enabled: false
+    openstack_ossyslog_handler_enabled: false
     cluster_internal_protocol: http
   keystone:
     server:
@@ -44,6 +45,8 @@
             enabled: true
           fluentd:
             enabled: ${_param:openstack_fluentd_handler_enabled}
+          ossyslog:
+            enabled: ${_param:openstack_ossyslog_handler_enabled}
       message_queue:
         engine: rabbitmq
         host: ${_param:cluster_vip_address}
diff --git a/metadata/service/server/single.yml b/metadata/service/server/single.yml
index f17cfe9..9357c7c 100644
--- a/metadata/service/server/single.yml
+++ b/metadata/service/server/single.yml
@@ -6,6 +6,7 @@
   _param:
     openstack_log_appender: false
     openstack_fluentd_handler_enabled: false
+    openstack_ossyslog_handler_enabled: false
     keystone_service_protocol: http
   keystone:
     server:
@@ -44,6 +45,8 @@
             enabled: true
           fluentd:
             enabled: ${_param:openstack_fluentd_handler_enabled}
+          ossyslog:
+            enabled: ${_param:openstack_ossyslog_handler_enabled}
       message_queue:
         engine: rabbitmq
         host: ${_param:single_address}