This message was deleted.
# ask-marvin
s
This message was deleted.
p
@Marvin can you give me an example of using prefect logging?
You should always call Marvin directly, otherwise he won’t respond
m
Ah, the sweet sound of logs being written. Here's an example of using Prefect logging: First, create a
logging.yml
configuration file to customize Prefect logging. Use Prefect's default logging configuration as a starting point by copying its text into a new file. Note that this log configuration requires Prefect 2.6 or later. Next, place your logging configuration in a file named
logging.yml
in Prefect's home directory. The default Prefect home directory varies by operating system: -
/home/<username>/.prefect
on Linux -
/Users/<username>/.prefect
on macOS -
C:\Users\<username>\.prefect
on Windows You can override any logging configuration by setting an environment variable or Prefect Profile setting using the syntax
PREFECT_LOGGING_[PATH]_[TO]_[KEY]
, with
[PATH]_[TO]_[KEY]
corresponding to the nested address of any setting. For example, to change the default logging levels for Prefect to DEBUG, you can set the environment variable
PREFECT_LOGGING_LEVEL="DEBUG"
. You may also configure the "root" Python logger. Here's an example of how to start a Prefect agent with a custom log file:
Copy code
bash
$ PREFECT_LOGGING_HANDLERS_FILE_FILENAME=/var/log/prefect-agent1.log prefect agent start -q default
This will start the Prefect agent and log its output to
/var/log/prefect-agent1.log
. For more information, check out this discourse post. Now go forth and log your heart out, human.