From d4e30977dd34b18a56e4e0a384fa4a0b2d9499e0 Mon Sep 17 00:00:00 2001 From: Grant Duncklee Date: Wed, 17 Apr 2024 10:22:46 -0400 Subject: [PATCH] feat: add logging for security baseline (#166) Adds logging to comply with security baseline requirements. Co-authored-by: Grant Duncklee --- Dockerfile | 4 ++-- log-config.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 log-config.yml diff --git a/Dockerfile b/Dockerfile index 30a0e4a9..74c8d3e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /usr/app RUN pip install poetry -COPY poetry.lock pyproject.toml alembic.ini ./ +COPY poetry.lock pyproject.toml alembic.ini log-config.yml ./ RUN poetry config virtualenvs.create false RUN poetry install --no-root @@ -16,4 +16,4 @@ WORKDIR /usr/app/src EXPOSE 8888 -CMD ["uvicorn", "sbl_filing_api.main:app", "--host", "0.0.0.0", "--port", "8888"] \ No newline at end of file +CMD ["uvicorn", "sbl_filing_api.main:app", "--host", "0.0.0.0", "--port", "8888", "--log-config", "log-config.yml"] diff --git a/log-config.yml b/log-config.yml new file mode 100644 index 00000000..1c552d9a --- /dev/null +++ b/log-config.yml @@ -0,0 +1,34 @@ +version: 1 +disable_existing_loggers: False +formatters: + default: + "()": uvicorn.logging.DefaultFormatter + format: '%(levelprefix)s [%(asctime)s] %(message)s' + use_colors: null + datefmt: '%d-%m-%Y %H:%M:%S' + access: + "()": uvicorn.logging.AccessFormatter + format: '%(levelprefix)s [%(asctime)s] %(client_addr)s - "%(request_line)s" %(status_code)s' + datefmt: '%d-%m-%Y %H:%M:%S' +handlers: + default: + formatter: default + class: logging.StreamHandler + stream: ext://sys.stderr + access: + formatter: access + class: logging.StreamHandler + stream: ext://sys.stdout +loggers: + uvicorn: + level: INFO + handlers: + - default + propagate: no + uvicorn.error: + level: INFO + uvicorn.access: + level: INFO + handlers: + - access + propagate: no \ No newline at end of file