folks, I'm coming from a luigi background, where w...
# ask-community
j
folks, I'm coming from a luigi background, where we can add custom loggers on top of luigi loggers:
Copy code
[core]
logging_conf_file = logging.cfg
then
Copy code
[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.
k
Hey @Jean Da Rolt, yep we have this .
j
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:
Copy code
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?
z
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
j
ok, thank you