django中使用logfire
安装
pip install 'logfire[django]'
settings.py
import logfire
# ...All the other settings...
# Add the following lines at the end of the file
logfire.configure()
logfire.instrument_django()
## 如果这个不行就换
from logging import basicConfig
logfire.configure()
basicConfig(handlers=[logfire.LogfireLoggingHandler()])
配置环境变量方式登录避免手动的logfire auth
LOGFIRE_TOKEN=xxY5JPtTMxMTtQH72hbX9w9brGPlw94VRsGVfVh02Qzp
在项目manage.py文件夹下执行
logfire projects use xxxxxxx
启动项目打开链接查看日志
https://logfire.pydantic.dev/Chen-Hai-F