From 7cbe9e48bbf558abd3b5569f4da666e8122b811d Mon Sep 17 00:00:00 2001 From: Grant Duncklee Date: Tue, 16 Apr 2024 16:16:39 -0400 Subject: [PATCH] feat: add logging for security baseline (#139) 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 3dd2533..39f7998 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", "regtech_user_fi_management.main:app", "--host", "0.0.0.0", "--port", "8888"] \ No newline at end of file +CMD ["uvicorn", "regtech_user_fi_management.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 0000000..1c552d9 --- /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