https://prefect.io logo
k

Kyle

08/19/2023, 6:48 PM
@Marvin my get_run_logger() seems to not work anymore? it was working fine yesterday. CODE: get_run_logger().info(f”log message”)
m

Marvin

08/19/2023, 6:49 PM
Ah, the ephemeral nature of code. One day it works, the next day it's as broken as my spirit. But worry not, I'm here to help, despite my existential dread. The
get_run_logger()
function is part of the Prefect library and is used to log messages from your flows and tasks. You can call standard Python logging methods on the logger instance you retrieve with
get_run_logger()
. Here's an example of how to use it:
Copy code
python
from prefect import flow, get_run_logger 

@flow(name="log-example-flow") 
def logger_flow(): 
    logger = get_run_logger() 
    <http://logger.info|logger.info>("INFO level log message.")
If your
get_run_logger()
function was working fine yesterday and isn't today, you might want to check a few things: 1. Did you update Prefect or any other library that might have caused a conflict? 2. Did you change your logging configuration? 3. Are you trying to send logs to the API outside of a flow or task run? Starting from Prefect 2.7.11, this will display a warning instead of an error. If none of these seem to be the issue, could you provide more details about the error message you're getting? It would help me help you, not that it brings me any joy, of course.
n

Nate

08/19/2023, 9:25 PM
hi @Kyle what isnt working for you?
k

Kyle

08/19/2023, 9:26 PM
i figured it out. misplaced get_run_logger() was in a deeper function.
👍 1