diff --git a/AUTHORS b/AUTHORS index 5315e417cc..b9e19f9328 100644 --- a/AUTHORS +++ b/AUTHORS @@ -79,3 +79,4 @@ Ye Jia Xu (xyj.asmy@gmail.com) Pete Zaitcev (zaitcev@kotori.zaitcev.us) Josh Kearney (josh@jk0.org) Vincent Untz (vuntz@suse.com) +Tsuyuzaki Kota (tsuyuzaki.kota@lab.ntt.co.jp) diff --git a/swift/common/middleware/proxy_logging.py b/swift/common/middleware/proxy_logging.py index 83bcd15e7a..7248f04de2 100644 --- a/swift/common/middleware/proxy_logging.py +++ b/swift/common/middleware/proxy_logging.py @@ -94,7 +94,8 @@ class ProxyLoggingMiddleware(object): self.app = app self.log_hdrs = conf.get('log_headers', 'no').lower() in TRUE_VALUES access_log_conf = {} - for key in ('log_facility', 'log_name', 'log_level'): + for key in ('log_facility', 'log_name', 'log_level', 'log_udp_host', + 'log_udp_port'): value = conf.get('access_' + key, conf.get(key, None)) if value: access_log_conf[key] = value diff --git a/swift/common/utils.py b/swift/common/utils.py index cfc0a1d46b..1f3ed26a5f 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -533,6 +533,8 @@ def get_logger(conf, name=None, log_to_console=False, log_route=None, log_facility = LOG_LOCAL0 log_level = INFO log_name = swift + log_udp_host = (disabled) + log_udp_port = logging.handlers.SYSLOG_UDP_PORT log_statsd_host = (disabled) log_statsd_port = 8125 log_statsd_default_sample_rate = 1 @@ -564,13 +566,19 @@ def get_logger(conf, name=None, log_to_console=False, log_route=None, # facility for this logger will be set by last call wins facility = getattr(SysLogHandler, conf.get('log_facility', 'LOG_LOCAL0'), SysLogHandler.LOG_LOCAL0) - log_address = conf.get('log_address', '/dev/log') - try: - handler = SysLogHandler(address=log_address, facility=facility) - except socket.error, e: - if e.errno != errno.ENOTSOCK: # Socket operation on non-socket - raise e - handler = SysLogHandler(facility=facility) + udp_host = conf.get('log_udp_host') + if udp_host: + udp_port = conf.get('log_udp_port', logging.handlers.SYSLOG_UDP_PORT) + handler = SysLogHandler(address=(udp_host, udp_port), + facility=facility) + else: + log_address = conf.get('log_address', '/dev/log') + try: + handler = SysLogHandler(address=log_address, facility=facility) + except socket.error, e: + if e.errno != errno.ENOTSOCK: # Socket operation on non-socket + raise e + handler = SysLogHandler(facility=facility) handler.setFormatter(formatter) logger.addHandler(handler) get_logger.handler4logger[logger] = handler diff --git a/swift/proxy/server.py b/swift/proxy/server.py index 22c5376fbc..45e1f7d23f 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -1870,7 +1870,8 @@ class BaseApplication(object): if logger is None: self.logger = get_logger(conf, log_route='proxy-server') access_log_conf = {} - for key in ('log_facility', 'log_name', 'log_level'): + for key in ('log_facility', 'log_name', 'log_level', + 'log_udp_host', 'log_udp_port'): value = conf.get('access_' + key, conf.get(key, None)) if value: access_log_conf[key] = value