logowanie dla health

This commit is contained in:
Mateusz Gruszczyński
2025-10-06 08:51:41 +02:00
parent e62421d374
commit 2d4834a2be
3 changed files with 39 additions and 2 deletions

View File

@@ -5,4 +5,4 @@ RUN apt-get update && apt-get install -y build-essential libmaxminddb0 libmaxmin
RUN pip install --no-cache-dir -r app/requirements.txt RUN pip install --no-cache-dir -r app/requirements.txt
COPY . /app COPY . /app
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-config", "logging.yml"]

View File

@@ -4,7 +4,7 @@ services:
container_name: ip-geo-api container_name: ip-geo-api
restart: unless-stopped restart: unless-stopped
ports: ports:
- "${HOST_PORT:-8080}:8000" - "${PORT:-8080}:8000"
healthcheck: healthcheck:
test: test:
[ [

37
logging.yml Normal file
View File

@@ -0,0 +1,37 @@
version: 1
disable_existing_loggers: False
filters:
ignore_health:
(): logging.Filter
filter: >
lambda record: "/health" not in record.getMessage()
formatters:
default:
format: '%(levelprefix)s %(client_addr)s - "%(request_line)s" %(status_code)s'
use_colors: true
handlers:
access:
class: logging.StreamHandler
formatter: default
filters: [ignore_health]
default:
class: logging.StreamHandler
formatter: default
loggers:
uvicorn:
level: INFO
handlers: [default]
propagate: no
uvicorn.error:
level: INFO
handlers: [default]
propagate: no
uvicorn.access:
level: INFO
handlers: [access]
propagate: no