3
2

More than 3 years have passed since last update.

Python loggingでsyslog出力するサンプルプログラム

Posted at
#!/usr/bin/python  
# -*- coding: utf-8 -*-
import logging
import logging.handlers

logging.basicConfig(filename='/tmp/logger.log', level=logging.DEBUG)
log = logging.getLogger("test_logge_name")

syslog_handler = logging.handlers.SysLogHandler(address="/dev/log", facility=logging.handlers.SysLogHandler.LOG_LOCAL1)
#syslog_handler.setLevel(logging.WARNING)

log.addHandler(syslog_handler)
log.debug('Test Debug message')
log.info('Test Info message')
log.warning('Test Warning message')
log.error('Test Error message')
log.critical('Test Critical message')
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2