Correct the position of the syslog handler

Correct the position of the syslog handler,
then the syslog handler can have same settings with
other handlers.

Change-Id: I15163f1dd12713c71d42efdb128f8d12ec5dc307
Closes-Bug: #1399088
This commit is contained in:
YangLei
2014-12-20 15:59:47 +08:00
parent 6301575fef
commit 250315b7b2

View File

@@ -230,6 +230,20 @@ def _setup_logging_from_conf(conf, project, version):
logging.ERROR)
log_root.addHandler(handler)
if conf.use_syslog:
try:
facility = _find_facility_from_conf(conf)
# TODO(bogdando) use the format provided by RFCSysLogHandler
# after existing syslog format deprecation in J
if conf.use_syslog_rfc_format:
syslog = handlers.RFCSysLogHandler(facility=facility)
else:
syslog = logging.handlers.SysLogHandler(facility=facility)
log_root.addHandler(syslog)
except socket.error:
log_root.error('Unable to add syslog handler. Verify that syslog '
'is running.')
datefmt = conf.log_date_format
for handler in log_root.handlers:
# NOTE(alaski): CONF.log_format overrides everything currently. This
@@ -263,21 +277,6 @@ def _setup_logging_from_conf(conf, project, version):
else:
logger.setLevel(level_name)
if conf.use_syslog:
try:
facility = _find_facility_from_conf(conf)
# TODO(bogdando) use the format provided by RFCSysLogHandler
# after existing syslog format deprecation in J
if conf.use_syslog_rfc_format:
syslog = handlers.RFCSysLogHandler(facility=facility)
else:
syslog = logging.handlers.SysLogHandler(facility=facility)
log_root.addHandler(syslog)
except socket.error:
log_root.error('Unable to add syslog handler. Verify that syslog '
'is running.')
_loggers = {}