LoggerFile Rotation
Daily Log Naming
The logger uses date-based file naming to organize log output by day and rotation sequence.
Each generated log file includes:
- the current date
- a sequential rotation number
Example file names:
2026-05-11-0001.log
2026-05-11-0002.log
2026-05-12-0001.logThis naming strategy makes it easier to:
- identify logs by date
- track rotated files
- archive logs
- debug production incidents
- integrate with external log processing systems
Example configuration:
package main
import (
"log/slog"
"github.com/netlifeguru/logger"
)
func main() {
closer, err := logger.Init(logger.Config{
Dir: "./logs",
MaxFileSize: 10 * 1024 * 1024,
})
if err != nil {
slog.Error(err.Error())
}
defer closer.Close()
slog.Info("application started")
}Generated directory structure:
logs/
├── 2026-05-11-0001.log
├── 2026-05-11-0002.log
└── 2026-05-12-0001.logThe sequence number increases automatically whenever file rotation occurs during the same day.
A new daily sequence starts automatically after the date changes.