-
-
Save finloop/0d4c8bf3af3729c961418f382a158ec8 to your computer and use it in GitHub Desktop.
Docker Python logger output to stdout
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 logging | |
from sys import stdout | |
# Define logger | |
logger = logging.getLogger('mylogger') | |
logger.setLevel(logging.DEBUG) # set logger level | |
logFormatter = logging.Formatter\ | |
("%(name)-12s %(asctime)s %(levelname)-8s %(filename)s:%(funcName)s %(message)s") | |
consoleHandler = logging.StreamHandler(stdout) #set streamhandler to stdout | |
consoleHandler.setFormatter(logFormatter) | |
logger.addHandler(consoleHandler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment