Closed kaykhancheckpoint closed 1 year ago
I'm trying to use this library so i can output json logs to stdout.
src/logger.py
import logging from pythonjsonlogger import jsonlogger logger = logging.getLogger() logHandler = logging.StreamHandler() formatter = jsonlogger.JsonFormatter() logHandler.setFormatter(formatter) logger.addHandler(logHandler)
src/testlogger.py
from src.logger import logger print("here") logger.info({"hello": "world"})
python src/testlogger.py
When i run the above command, the print statement runs but i don't see the hello world log in json. Theres nothing else outputted.
You forgot to set the level:
logger.setLevel(logging.INFO)
I'm trying to use this library so i can output json logs to stdout.
src/logger.py
src/testlogger.py
When i run the above command, the print statement runs but i don't see the hello world log in json. Theres nothing else outputted.