Django¶
The logfire.instrument_django()
method can be used to instrument the Django web framework with Logfire.
Installation¶
Install logfire
with the django
extra:
pip install 'logfire[django]'
uv add 'logfire[django]'
rye add logfire -E django
poetry add 'logfire[django]'
Info
If you use are using the Asynchronous support of Django, you'll also need to
install the asgi
extra:
pip install 'logfire[django,asgi]'
uv add 'logfire[django,asgi]'
rye add logfire -E django -E asgi
poetry add 'logfire[django,asgi]'
Usage¶
In the settings.py
file, add the following lines:
import logfire
# ...All the other settings...
# Add the following lines at the end of the file
logfire.configure()
logfire.instrument_django()
logfire.instrument_django()
uses the
OpenTelemetry Django Instrumentation package,
which you can find more information about here.