Created
May 4, 2016 15:13
-
-
Save elzibubble/86d1abc851bd3d3d6d23f4dc8eaeec4a to your computer and use it in GitHub Desktop.
Remove log handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[loggers] | |
keys: root | |
[handlers] | |
keys: screen, screen2 | |
[formatters] | |
keys: context | |
[logger_root] | |
qualname: root | |
handlers: screen, screen2 | |
level: NOTSET | |
[handler_screen] | |
class=StreamHandler | |
formatter=context | |
level=NOTSET | |
args=(sys.stdout,) | |
[handler_screen2] | |
class=StreamHandler | |
formatter=context | |
level=NOTSET | |
args=(sys.stdout,) | |
# datefmt must be set otherwise you end up with too many (msecs) fields | |
[formatter_context] | |
class: oslo_log.formatters.ContextFormatter | |
args: (datefmt=datefmt) | |
format: %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user)s %(tenant)s] %(instance)s%(message)s | |
datefmt: %Y-%m-%d %H:%M:%S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import logging.config as logcfg | |
import oslo_config.cfg as cfg | |
from oslo_log import log as log | |
def main(): | |
os.system('clear') | |
CONF = cfg.CONF | |
log.register_options(CONF) | |
CONF() | |
CONF.log_config_append = "multihandler.ini" | |
log.set_defaults() | |
log.setup(CONF, 'logxp') | |
root = log.getLogger("") | |
root.error("one") | |
logcfg.fileConfig('multihandler2.ini', disable_existing_loggers=False) | |
root.error("two") | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[loggers] | |
keys: root | |
[handlers] | |
keys: screen | |
[formatters] | |
keys: context | |
[logger_root] | |
qualname: root | |
handlers: screen | |
level: NOTSET | |
[handler_screen] | |
class=StreamHandler | |
formatter=context | |
level=NOTSET | |
args=(sys.stdout,) | |
# datefmt must be set otherwise you end up with too many (msecs) fields | |
[formatter_context] | |
class: oslo_log.formatters.ContextFormatter | |
args: (datefmt=datefmt) | |
format: %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user)s %(tenant)s] %(instance)s%(message)s | |
datefmt: %Y-%m-%d %H:%M:%S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2016-05-04 16:12:09.251 15002 ERROR root [-] one | |
2016-05-04 16:12:09.251 15002 ERROR root [-] one | |
2016-05-04 16:12:09.252 15002 ERROR root [-] two |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment