68 lines
2.2 KiB
JSON
68 lines
2.2 KiB
JSON
{
|
|
"_comment": "Template for logging configuration. Customize this to fit your needs.",
|
|
"version": 1,
|
|
"disable_existing_loggers": false,
|
|
"formatters": {
|
|
"standard": {
|
|
"_comment": "Standard log format with timestamp, level, and message.",
|
|
"format": "%(asctime)s - %(levelname)s - %(name)s - %(correlation_id)s - %(message)s"
|
|
},
|
|
"json": {
|
|
"_comment": "JSON log format for easier parsing by log aggregation tools.",
|
|
"format": "{\"timestamp\": \"%(asctime)s\", \"level\": \"%(levelname)s\", \"name\": \"%(name)s\", \"correlation_id\": \"%(correlation_id)s\", \"message\": \"%(message)s\", \"module\": \"%(module)s\", \"funcName\": \"%(funcName)s\", \"lineno\": %(lineno)d}"
|
|
}
|
|
},
|
|
"handlers": {
|
|
"console": {
|
|
"_comment": "Console handler for local development.",
|
|
"class": "logging.StreamHandler",
|
|
"level": "INFO",
|
|
"formatter": "standard",
|
|
"stream": "ext://sys.stdout"
|
|
},
|
|
"file": {
|
|
"_comment": "File handler for persistent logging.",
|
|
"class": "logging.handlers.RotatingFileHandler",
|
|
"level": "DEBUG",
|
|
"formatter": "standard",
|
|
"filename": "/var/log/api_requests.log",
|
|
"maxBytes": 10485760,
|
|
"backupCount": 5,
|
|
"encoding": "utf8"
|
|
},
|
|
"json_file": {
|
|
"_comment": "JSON file handler for persistent logging in JSON format",
|
|
"class": "logging.handlers.RotatingFileHandler",
|
|
"level": "DEBUG",
|
|
"formatter": "json",
|
|
"filename": "/var/log/api_requests.json",
|
|
"maxBytes": 10485760,
|
|
"backupCount": 5,
|
|
"encoding": "utf8"
|
|
}
|
|
},
|
|
"loggers": {
|
|
"api_request_logger": {
|
|
"_comment": "Logger for API requests.",
|
|
"level": "DEBUG",
|
|
"handlers": ["console", "file", "json_file"],
|
|
"propagate": false
|
|
},
|
|
"other_module": {
|
|
"_comment": "Example of another module's logger.",
|
|
"level": "WARNING",
|
|
"handlers": ["console"],
|
|
"propagate": true
|
|
}
|
|
},
|
|
"root": {
|
|
"_comment": "Root logger configuration.",
|
|
"level": "WARNING",
|
|
"handlers": ["console"]
|
|
},
|
|
"correlation_id": {
|
|
"_comment": "Configuration for correlation ID generation.",
|
|
"header_name": "X-Correlation-ID",
|
|
"generator": "uuid"
|
|
}
|
|
} |