日志补充

This commit is contained in:
lhx
2025-09-27 11:54:22 +08:00
parent 4fd9e635b0
commit b7ad3eb087
3 changed files with 13 additions and 5 deletions

2
.gitignore vendored
View File

@@ -2,6 +2,8 @@
*.md *.md
**/__pycache__/ **/__pycache__/
*.pyc *.pyc
logs/
*.log
!README.md !README.md

View File

@@ -26,11 +26,11 @@ RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码 # 复制应用代码
COPY . . COPY . .
# 创建日志目录 # 创建日志目录并设置权限
RUN mkdir -p /app/logs RUN mkdir -p /app/logs && chmod 755 /app/logs
# 暴露端口 # 暴露端口
EXPOSE 8000 EXPOSE 8000
# 启动命令 # 启动命令,启用详细日志
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--access-log"] CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--access-log", "--log-level", "info"]

View File

@@ -1,11 +1,17 @@
import uvicorn import uvicorn
from app.main import app from app.main import app
from app.core.config import settings from app.core.config import settings
from app.core.logging_config import setup_logging
if __name__ == "__main__": if __name__ == "__main__":
# 确保日志系统已初始化
setup_logging()
uvicorn.run( uvicorn.run(
"app.main:app", "app.main:app",
host=settings.APP_HOST, host=settings.APP_HOST,
port=settings.APP_PORT, port=settings.APP_PORT,
reload=settings.APP_DEBUG reload=settings.APP_DEBUG,
access_log=True,
log_level="info"
) )