Rotating log file with retention
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
`simple-log` is a small convenience layer on top of Racket's logging system.
|
||||
It provides generated procedures for the standard log levels and supports
|
||||
logging to the display, a file, custom callbacks, and a filterable in-memory
|
||||
store.
|
||||
logging to the display, regular or daily rotating files, custom callbacks, and
|
||||
a filterable in-memory store.
|
||||
|
||||
```racket
|
||||
#lang racket
|
||||
@@ -31,3 +31,22 @@ Topic filters can select multiple topics or invert a match:
|
||||
|
||||
The Scribble manual documents logger definitions, destinations, log levels,
|
||||
synchronization, and all in-memory store operations.
|
||||
## Rotating log files
|
||||
|
||||
Daily rotation keeps the current log as plain text and gzip-compresses older
|
||||
days. The retention value counts the current day as well.
|
||||
|
||||
```racket
|
||||
(sl-log-to-rotating-file "application.log") ; 7 days
|
||||
(sl-log-to-rotating-file "application.log" 14) ; 14 days
|
||||
```
|
||||
|
||||
With a retention of 7 days the files look like this:
|
||||
|
||||
```text
|
||||
application.log
|
||||
application.log.2026-08-28.gz
|
||||
application.log.2026-08-27.gz
|
||||
...
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user