0

here I have a simple code initializing a new logger and just log a simple info message. But the INFO message turns red in console. I thought I should be gray and I want it gray. Debug mode also returns red message in the console.

import logging


logger = logging.getLogger('main')
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter("%(name)s %(asctime)s %(levelname)s %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.info('START EXECUTION')

Even when I use this solution How can I color Python logging output? it doesnt help, info and debug messages remain red.

enter image description here

  • Same problem discussed in the thread [here](https://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output?page=1&tab=scoredesc#tab-top) – Martin Dobruský Nov 21 '22 at 10:06
  • 1
    This has very likely nothing to do with Python and logging; the links provided/suggested are therefore also useless. Instead, this is likely your terminal, or rather, the IDE: it colours output to stderr red, and output to stdout grey. Try `print(123)` vs `import sys; print(123, file=sys.stderr)`, and see if you also get a grey versus red difference. – 9769953 Nov 21 '22 at 10:29

0 Answers0