<@ULVA73B9P> I have a logging statement inside a o...
# ask-marvin
a
@Marvin I have a logging statement inside a on_failure hook but I can’t see any logs being produced; is there any special configuration I must do?
m
It seems there isn't a direct answer to your question in the Prefect documentation about why logs might not be produced in an
on_failure
hook. However, general logging configuration in Prefect is detailed in a guide. You may need to ensure that the log level is appropriate for the messages you're expecting. For instance, if you're using
logger.debug()
within the
on_failure
hook, but the logging configuration only outputs logs at level
WARNING
or above, your debug-level logs won't appear. You can configure the logs by setting environment variables or by using Prefect Profile settings to set the appropriate logging levels. For example, setting an environment variable
PREFECT_LOGGING_LEVEL="DEBUG"
would configure Prefect to output debug level logs. For more detailed logging configuration, visit the Prefect Logging Guide. If adjusting the logging level does not resolve your issue, consider checking other factors such as environment configurations, potential exceptions within the hook itself, or issues with how the logs are retrieved or viewed. Remember, it's important to ensure that any logging configuration changes you make are appropriate for your deployment environment and security policies, as verbose logging can sometimes include sensitive information.
n
if you're in a hook, you're not in a run context, so you cant use
get_run_logger
, in hooks you should use
get_logger
to get a logger that you can use anywhere, but those wont go to the API
🙌 1
a
@Nate we ended up calling the logs api from the hook 🙂
n
okay! out of curiosity - whats the use case for logs in a hook? I usually gravitate towards events for stuff in hooks, but are you self hosting server?
a
we send pubsubs to other services and want to have confirmation that the message was sent in the logs
n
gotcha, cool - thanks!