2

I am using Kedro but I can't get my logging file to be used. I am following the tutorial. The log file was created but is still empty.

Steps done:

  1. Configured logging
class ProjectContext(KedroContext):

    def _setup_logging(self) -> None:
        log = logging.getLogger(__name__)
        handler = TimedRotatingFileHandler(filename='logs/mypipeline.log', when='d', interval=1)
        f_format = logging.Formatter('%(asctime)s %(levelname)s %(funcName)s %(lineno)d %(message)s ')
        handler.setFormatter(f_format)
        log.addHandler(handler)
        log.setLevel(logging.DEBUG)
  1. Use logging (in my nodes.py file)
import logging 
log = logging.getLogger(__name__)  
log.warning("Issue warning")  
log.info("Send information")

And after running the pipeline the log file is created but keeps empty.

Any advice?

pppery
  • 3,731
  • 22
  • 33
  • 46
Antunes
  • 41
  • 4
  • It might be because the location `'logs/mypipeline.log'` is relative to your `run.py`, so maybe you are trying to find the logs at the wrong place? Could you check to see if there is any logs directory under `src/`? – Lim H. Oct 16 '20 at 17:08
  • Is class `ProjectContext` in different file than ‘nodes.py’ ? – dragon2fly Oct 17 '20 at 13:42
  • @LimH. , thank you but the file was created on the right place. I just dont get the messages. – Antunes Oct 18 '20 at 23:29
  • @dragon2fly, yes, according to the tutorial, is at the entry point of my application (e.g., src//run.py). – Antunes Oct 18 '20 at 23:31
  • Ok, problem solved! It was missing the logger definition on the logging.yml file! Thank you guys for your support! – Antunes Oct 19 '20 at 00:18

1 Answers1

2

Ok, problem solved! It was missing the logger definition on the logging.yml file! Thank you guys for your support!

Antunes
  • 41
  • 4