Configuration
You can use the following ways to configure Logfire:
- Programmatically via
logfire.configure()
- Using environment variables
- Using a configuration file (
pyproject.toml
)
The order of precedence is as above.
Programmatically via configure
¶
For more details, please refer to our API documentation.
Using environment variables¶
You can use the following environment variables to configure Logfire:
Name | Description |
---|---|
LOGFIRE_BASE_URL | The base URL of the Logfire backend. Primarily for testing purposes. |
LOGFIRE_SEND_TO_LOGFIRE | Whether to send spans to Logfire. |
LOGFIRE_TOKEN | Token for the Logfire API. |
LOGFIRE_SERVICE_NAME | Name of the service emitting spans. For further details, please refer to the Service section. |
LOGFIRE_SERVICE_VERSION | Version number of the service emitting spans. For further details, please refer to the Service section. |
LOGFIRE_ENVIRONMENT | Environment in which the service is running. For further details, please refer to the Deployment section. |
LOGFIRE_TRACE_SAMPLE_RATE | Head sampling rate for traces. |
LOGFIRE_CREDENTIALS_DIR | The directory where to store the configuration file. |
LOGFIRE_CONSOLE | Whether to enable/disable the console exporter. |
LOGFIRE_CONSOLE_COLORS | Whether to use colors in the console. |
LOGFIRE_CONSOLE_SPAN_STYLE | How spans are shown in the console. |
LOGFIRE_CONSOLE_INCLUDE_TIMESTAMP | Whether to include the timestamp in the console. |
LOGFIRE_CONSOLE_VERBOSE | Whether to log in verbose mode in the console. |
LOGFIRE_CONSOLE_MIN_LOG_LEVEL | Minimum log level to show in the console. |
LOGFIRE_CONSOLE_SHOW_PROJECT_LINK | Whether to enable/disable the console exporter. |
LOGFIRE_PYDANTIC_PLUGIN_RECORD | Whether instrument Pydantic validation.. |
LOGFIRE_PYDANTIC_PLUGIN_INCLUDE | Set of items that should be included in Logfire Pydantic plugin instrumentation. |
LOGFIRE_PYDANTIC_PLUGIN_EXCLUDE | Set of items that should be excluded from Logfire Pydantic plugin instrumentation. |
LOGFIRE_INSPECT_ARGUMENTS | Whether to enable the f-string magic feature. On by default for Python 3.11 and above. |
LOGFIRE_IGNORE_NO_CONFIG | Whether to show a warning message if logfire if used without calling logfire.configure() |
When using environment variables, you still need to call logfire.configure()
,
but you can leave out the arguments.
Using a configuration file (pyproject.toml
)¶
You can use the pyproject.toml
to configure Logfire.
Here's an example:
[tool.logfire]
project_name = "My Project"
console_colors = "never"
The keys are the same as the parameters of logfire.configure()
.