diff --git a/etc/glance-api.conf b/etc/glance-api.conf index e1c4d81c6e..ae396db9f9 100644 --- a/etc/glance-api.conf +++ b/etc/glance-api.conf @@ -20,12 +20,18 @@ bind_port = 9292 # file for both the API and registry servers! log_file = /var/log/glance/api.log -# Send logs to syslog (/dev/log) instead of to file specified by `log_file` -use_syslog = False - # Backlog requests when creating socket backlog = 4096 +# ================= Syslog Options ============================ + +# Send logs to syslog (/dev/log) instead of to file specified +# by `log_file` +use_syslog = False + +# Facility to use. If unset defaults to LOG_USER. +# syslog_log_facility = LOG_LOCAL0 + # ================= SSL Options =============================== # Certificate file to use when starting API server securely diff --git a/etc/glance-registry.conf b/etc/glance-registry.conf index c9d32cbbcf..4b96258f23 100644 --- a/etc/glance-registry.conf +++ b/etc/glance-registry.conf @@ -15,9 +15,6 @@ bind_port = 9191 # file for both the API and registry servers! log_file = /var/log/glance/registry.log -# Send logs to syslog (/dev/log) instead of to file specified by `log_file` -use_syslog = False - # Backlog requests when creating socket backlog = 4096 @@ -43,6 +40,15 @@ api_limit_max = 1000 # default to `limit_param_default` limit_param_default = 25 +# ================= Syslog Options ============================ + +# Send logs to syslog (/dev/log) instead of to file specified +# by `log_file` +use_syslog = False + +# Facility to use. If unset defaults to LOG_USER. +# syslog_log_facility = LOG_LOCAL1 + # ================= SSL Options =============================== # Certificate file to use when starting registry server securely diff --git a/glance/common/cfg.py b/glance/common/cfg.py index 0cb7abfb68..93ae517dde 100644 --- a/glance/common/cfg.py +++ b/glance/common/cfg.py @@ -1118,6 +1118,9 @@ class CommonConfigOpts(ConfigOpts): BoolOpt('use-syslog', default=False, help='Use syslog for logging.'), + StrOpt('syslog-log-facility', + default='LOG_USER', + help='syslog facility to receive log lines') ] def __init__(self, **kwargs): diff --git a/glance/common/config.py b/glance/common/config.py index 84b988ce42..4eea55d2f2 100644 --- a/glance/common/config.py +++ b/glance/common/config.py @@ -28,7 +28,6 @@ from glance import version from glance.common import cfg -from glance.common import utils from glance.common import wsgi @@ -77,7 +76,14 @@ def setup_logging(conf): formatter = logging.Formatter(conf.log_format, conf.log_date_format) if conf.use_syslog: - handler = logging.handlers.SysLogHandler(address='/dev/log') + try: + facility = getattr(logging.handlers.SysLogHandler, + conf.syslog_log_facility) + except AttributeError: + raise ValueError(_("Invalid syslog facility")) + + handler = logging.handlers.SysLogHandler(address='/dev/log', + facility=facility) elif conf.log_file: logfile = conf.log_file if conf.log_dir: