Thread
#prefect-community
    Jean Da Rolt

    Jean Da Rolt

    1 year ago
    folks, I'm coming from a luigi background, where we can add custom loggers on top of luigi loggers:
    [core]
    logging_conf_file = logging.cfg
    then
    [loggers]
    keys=root,app
    
    [handlers]
    keys=consoleHandler,StackDriveHandler
    ...
    Is there anything similar in Prefect? I do not want to add additional logs inside my tasks, but make prefect log using additional loggers.
    Kevin Kho

    Kevin Kho

    1 year ago
    Hey @Jean Da Rolt, yep we have this .
    Jean Da Rolt

    Jean Da Rolt

    1 year ago
    Hi Kevin, thanks for the reply. I may be wrong, but what the extra_loggers do is to take all messages from the listed loggers and send it to stdout by attaching a streamhandler for each of the elements. What I wanted is the oposite: attach a customHandler to Prefect Logger, inside the config. I know that this works:
    import logging
    
    from logging import StreamHandler
    
    class BlablaHandler(StreamHandler):
    
        def __init__(self):
            StreamHandler.__init__(self)
    
    
        def emit(self, record):
            msg = self.format(record)
            print("Printing inside handler")
            print(msg)
    
    logger = logging.getLogger()
    logger.addHandler(BlablaHandler())
    however I would prefer to have that in the prefect config file. Is that possible?
    Michael Adkins

    Michael Adkins

    1 year ago
    Hey Jean, that's not possible right now. We have a proposal to add config via a logging file like you showed above but it's not done yet.
    You have to write a custom
    get_logger
    function that, on logger retrieval, adds the extra handlers you want
    Jean Da Rolt

    Jean Da Rolt

    1 year ago
    ok, thank you