:question: Kedro logging question: We have a fasta...
# questions
f
Kedro logging question: We have a fastapi application where we define a AzureLogHandler at the beginning:
Copy code
logger = CorrelatedLogger.get_logger()

    log_handler = AzureLogHandler(connection_string=connection_string)
    logger.addHandler(log_handler)

    logger.setLevel(logging.INFO)
We then create a kedro session to get the catalog and load some datasets (we have to use a session because of certain hooks to allow us to load datasets). However, the creation of the session and loading of the associated
logging.yaml
completely breaks the logging config of the CorrelatedLogger … If I add the same logging config as in the snippet above after the kedro session was closed again. It all works. I did not expect the loading of the kedro project logging config to break any existing logging handlers or setup. Anyone got an idea?
Not super familiar with logging so might be something obvious
n
There is a line in the logging file that disable existing logger IRRC
I had an issue with it in the past, but I cannot think of the it immediately, let me try to pull the related issue
https://github.com/kedro-org/kedro/issues/792 I had a proposed fix here, can you see if it works for you?
f
If I add
incremental: True
I get the following
Copy code
File "/anaconda/envs/test/lib/python3.9/logging/config.py", line 508, in configure
    raise ValueError('No handler found with '
ValueError: No handler found with name 'console'
There is a line in the logging file that disable existing logger IRRC
This is set to False so I would expect nothing to happen to existing loggers
@Nok Lam Chan I see that in 0.19 the whole code is session that reads the logging is removed. Would that solve the problem?
n
@Florian d I don’t think that will solve the problem directly - the decoupling of ConfigLoader and logging solves other problem, and it also make sure logging is configured early enough. Previously logging is only initiated after session created so it cannot log things before that.
If I understand your situation, there is a web app started before KedroSession is created, and somehow Kedro clear the log handler of the web application? Two things you may try here: 1. adding the name of the Azurehandler in
logging.yml
2. Debug with
logging.dictConfig
directly, which is what Kedro use under the hood. There isn’t too much magic as we relies on the standard
logging
module to do the job. https://docs.python.org/3/library/logging.config.html#logging.config.dictConfig