<@ULVA73B9P> is the JsonFormatter still supported ...
# ask-marvin
j
@Marvin is the JsonFormatter still supported as a logging formatter to be used in logging.yaml ?
m
The
JsonFormatter
directly is not explicitly mentioned in the Prefect documentation for versions 2.x or 3.x. However, Prefect does provide ways to customize logging configurations using a
logging.yml
file, and you can employ any formatter supported by Python's standard logging module, including JSON formatters. Here are the steps you can take to configure a
JsonFormatter
in `logging.yml`: 1. Ensure you have a JSON formatter available, such as
python-json-logger
. 2. Create or modify your
logging.yml
file to include your JSON formatter settings. Here are useful links and references from the Prefect documentation: - Prefect 2.x Logging Guide: Prefect 2.x Logging - Prefect 3.x Logging Guide: Prefect 3.x Logging You can configure a
JsonFormatter
in the
logging.yml
like this:
Copy code
yaml
version: 1
formatters:
  json:
    '()': pythonjsonlogger.jsonlogger.JsonFormatter
handlers:
  console:
    class: logging.StreamHandler
    formatter: json
loggers:
  prefect:
    level: INFO
    handlers: [console]
    propagate: no
root:
  level: WARNING
  handlers: [console]
Ensure to install
python-json-logger
with:
Copy code
bash
pip install python-json-logger
For further details, refer to the links to the Prefect Logging guidelines provided above. If you face any issues, do check Prefect’s GitHub issues or feel free to ask for more specific advice.