Add custom log config

This commit is contained in:
Mac Chaffee 2025-05-25 14:49:04 -04:00
parent 8d409c5fe8
commit 9f7bcfcafa
3 changed files with 73 additions and 0 deletions

View File

@ -10,6 +10,8 @@ LETS_ENCRYPT_ENV=production
## All config: https://docs.mealie.io/documentation/getting-started/installation/backend-config/
ALLOW_SIGNUP=false
LOG_LEVEL=warn
# We use a custom log config to prevent logging to the filesystem and only log to stdout/stderr
LOG_CONFIG_OVERRIDE=/app/logconf-override.json
# TOKEN_TIME=8765
# TZ=UTC

View File

@ -29,6 +29,14 @@ services:
- DB_ENGINE=sqlite
# Upstream mistakenly adds the user to 1000 instead of 911
- PGID=1000
configs:
- source: log_config
target: /app/logconf-override.json
configs:
log_config:
name: ${STACK_NAME}_log_config_${LOG_CONFIG_VERSION}
file: logconf-override.json
networks:
proxy:

63
logconf-override.json Normal file
View File

@ -0,0 +1,63 @@
{
"version": 1,
"disable_existing_loggers": false,
"formatters": {
"simple": {
"format": "%(levelname)-8s %(asctime)s - %(message)s",
"datefmt": "%Y-%m-%dT%H:%M:%S"
},
"detailed": {
"format": "[%(levelname)s|%(module)s|L%(lineno)d] %(asctime)s: %(message)s",
"datefmt": "%Y-%m-%dT%H:%M:%S"
},
"access": {
"()": "uvicorn.logging.AccessFormatter",
"fmt": "%(levelname)-8s %(asctime)s - [%(client_addr)s] %(status_code)s \"%(request_line)s\"",
"datefmt": "%Y-%m-%dT%H:%M:%S"
}
},
"handlers": {
"stderr": {
"class": "logging.StreamHandler",
"level": "WARNING",
"formatter": "simple",
"stream": "ext://sys.stderr"
},
"stdout": {
"class": "logging.StreamHandler",
"level": "${LOG_LEVEL}",
"formatter": "simple",
"stream": "ext://sys.stdout"
},
"access": {
"class": "logging.StreamHandler",
"level": "${LOG_LEVEL}",
"formatter": "access",
"stream": "ext://sys.stdout"
}
},
"loggers": {
"root": {
"level": "${LOG_LEVEL}",
"handlers": [
"stderr",
"stdout"
]
},
"uvicorn.error": {
"handlers": [
"stderr",
"stdout"
],
"level": "${LOG_LEVEL}",
"propagate": false
},
"uvicorn.access": {
"handlers": [
"access"
],
"level": "${LOG_LEVEL}",
"propagate": false
}
}
}