-
-
Save Ruivalim/64794c4007facb3f7336bd65ba1436cc 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("%(asctime)s %(levelname)-8s %(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