NetLife Guru

Open source Go packages for fast, maintainable web systems. Built with a documentation-first approach.

Product
OverviewGolang packagesNews
Documentation
DocumentationGo LoggerGo RouterGo DB Form
Company
OverviewContactNewsGitHub
Community / Support
Supportinfo@netlife.guru
© 2026 NetLife Guru. All rights reserved.
GitHubinfo@netlife.guru
NetLife GuruNetLife GuruNetLife Guru
NetLife GuruNetLife GuruNetLife Guru
OverviewDocumentationNewsSupportContact

Golang packages

Logger Introduction
Automatic Log DirectoryFile RotationAutomatic CleanupDaily Log NamingGraceful Shutdown
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.log

This 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.log

The sequence number increases automatically whenever file rotation occurs during the same day.

A new daily sequence starts automatically after the date changes.

Automatic Cleanup

The logger automatically removes old rotated log files to prevent uncontrolled disk usage.

Graceful Shutdown

The logger returns a `Closer` instance during initialization to ensure that file handles and internal resources are released properly when the application exits.