Hi All, How do I include default loggers to be lo...
# prefect-community
m
Hi All, How do I include default loggers to be logged in the prefect UI? Right now I have a function that setup logs, for example
Copy code
def setup_logs():
    # Example config
    'root': {
            'level': 'DEBUG',
            'handlers': [
                'console',
                'info_file_handler',
                'fluent'
            ]
     }
     logging.config.dictConfig(logging_config)

class DoSomething():
    def run(self):
        setup_logs()
        <http://logger.info|logger.info>("Here")
The logging configurations sets up a default logger to stdout, a file handler, and also to a 3rd party log streaming service using fluent. I see the local file output, but not through the prefect UI.
Copy code
export PREFECT__LOGGING__EXTRA_LOGGERS="['root']"

[logging]
extra_loggers = "['root']"
I have setup a toml file, and tried to set the environmental variable before running the agent, and the flow itself. However I still do not see the logs in the prefect UI. Is there something else I need to do?
c
Hi Max - I’m not sure I follow your example, but in general, the
extra_loggers
configuration will add the appropriate logging handlers to your loggers at the first import-time of Prefect. Instead of creating an entirely new logger to re-route logs to a third party service, I recommend adding your additional handlers to the root prefect logger (which is already configured for the Prefect API):
Copy code
prefect_logger = prefect.utilities.configuration.logging.get_logger()

# add additional handlers to the prefect logger here