diff --git a/docs/configs/settings.md b/docs/configs/settings.md index 010c91875..254209332 100644 --- a/docs/configs/settings.md +++ b/docs/configs/settings.md @@ -612,6 +612,8 @@ logpath: /logfile/path By default, logs are sent both to `stdout` and to a file at the path specified. This can be changed by setting the `LOG_TARGETS` environment variable to one of `both` (default), `stdout` or `file`. +Log files rotate automatically when they reach 10 MiB. Up to five files are retained: the current `homepage.log` and four rotated files (`homepage1.log` through `homepage4.log`). The oldest rotated file is removed when a new one is created. + ## Show Container Stats You can show all docker or proxmox stats expanded in `settings.yaml`: diff --git a/src/utils/logger.js b/src/utils/logger.js index 5f12de077..4f244913b 100644 --- a/src/utils/logger.js +++ b/src/utils/logger.js @@ -50,6 +50,9 @@ function getFileLogger() { winston.format.printf(messageFormatter), ), filename: `${logpath}/logs/homepage.log`, + maxsize: 10 * 1024 * 1024, + maxFiles: 5, + tailable: true, handleExceptions: true, handleRejections: true, }); diff --git a/src/utils/logger.test.js b/src/utils/logger.test.js index 350b24686..c87fdb4f6 100644 --- a/src/utils/logger.test.js +++ b/src/utils/logger.test.js @@ -95,6 +95,9 @@ describe("utils/logger", () => { const transports = state.lastCreateLoggerArgs.transports; expect(transports).toHaveLength(1); expect(transports[0].opts.filename).toBe("/tmp/logs/homepage.log"); + expect(transports[0].opts.maxsize).toBe(10 * 1024 * 1024); + expect(transports[0].opts.maxFiles).toBe(5); + expect(transports[0].opts.tailable).toBe(true); }); it("defaults to both transports for unknown LOG_TARGETS and patches console methods", async () => {