|
- 1 #!/usr/bin/python
- 2 # -*- encoding: utf-8 -*-
- 3
- 4 import logging
- 5
- 6 syslogf = None
- 7
- 8 def init(name='root'):
- 9 global syslogf
- 10 syslogf = logging.FileHandler('/var/log/tasks.log')
- 11 syslogf.setLevel(logging.DEBUG)
- 12 syslogf.setFormatter(logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s',
- 13 '%Y-%m-%d,%H:%M:%S'))
- 14
- 15 logger = logging.getLogger(name)
- 16 logger.addHandler(syslogf)
- 17 logger.info('debug test')
- 18 # logger.warning('debug test')
- 19 return logger
- 20
- 21 def close():
- 22 syslogf.close()
- 23
- 24 init('test')
复制代码
为什么 info 级别的信息还是没有被记录呢?
谢谢。 |
|