-
Notifications
You must be signed in to change notification settings - Fork 0
/
testLogging.py
40 lines (35 loc) · 915 Bytes
/
testLogging.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
import logging
import logging.config
logging.config.dictConfig({
'version': 1,
'formatters': {
'standard': {
'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
},
},
'handlers':{
'console': {
'class' : 'logging.StreamHandler',
'formatter': 'standard',
'level' : 'INFO',
'stream' : 'ext://sys.stdout'
},
'file': {
'class' : 'logging.handlers.RotatingFileHandler',
'formatter': 'standard',
'filename': 'logconfig.log',
'maxBytes': 1024,
'backupCount': 3
}
},
'loggers': {
'': { # root logger
'handlers': ['console', 'file'],
'level': 'INFO',
'propagate': False
}
}
})
LOG = logging.getLogger('testlogger')
LOG.info('INFO log')