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

Automatic Log Directory

The logger automatically creates the configured log directory during initialization.

This removes the need to manually create directories before starting the application and ensures that log files can be written immediately after the logger is initialized.

By default, logs are stored in:

./logs

Custom directories can be configured using the Dir option:

package main

import (
	"log/slog"

	"github.com/netlifeguru/logger"
)

func main() {
	closer, err := logger.Init(logger.Config{
		Dir: "./storage/logs",
	})

	if err != nil {
		slog.Error(err.Error())
	}

	defer closer.Close()

	slog.Info("logger initialized")
}

Example generated structure:

storage/
└── logs/
    └── 2026-05-11-0001.log

This behavior is especially useful for:

  • fresh deployments
  • containerized environments
  • CI/CD pipelines
  • ephemeral infrastructure
  • automated server provisioning

Structured JSON Logging

The logger writes structured log entries as JSON, making logs easy to parse, search, and process in production environments.

File Rotation

The logger supports automatic file rotation based on both date and file size.