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
Thread Safe DesignOptimized File Writer
LoggerPerformance

Optimized File Writer

The logger includes an optimized file writer designed for high-throughput structured logging.

File writes are handled efficiently to reduce allocation overhead and keep logging predictable even in busy applications.

This is especially useful for:

  • HTTP APIs
  • background workers
  • queue consumers
  • long-running services
  • applications with frequent structured logs

Example usage:

package main

import (
	"log/slog"

	"github.com/netlifeguru/logger"
)

func main() {
	closer, err := logger.Init(logger.Config{
		Dir:            "./logs",
		TerminalOutput: false,
		MinLevel:       slog.LevelInfo,
	})

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

	defer closer.Close()

	slog.Info("file logging enabled",
		slog.String("service", "api"),
		slog.String("environment", "production"),
	)
}

Example file output:

{
  "time": "2026-05-11T12:56:31.879333+02:00",
  "level": "INFO",
  "msg": "file logging enabled",
  "service": "api",
  "environment": "production"
}

The file writer is optimized for:

  • structured JSON output
  • repeated log writes
  • concurrent application workloads
  • reduced allocation overhead
  • predictable file rotation behavior

For applications where logging is part of a hot path, this keeps persisted logs useful without introducing unnecessary runtime pressure.

Thread Safe Design

The logger is designed for concurrent use and can be safely shared across goroutines.

Project Information

Documentation links, performance characteristics, versioning policy, contribution guidelines, licensing, and project resources for the NLG Logger package.