Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Logging with `log` and Stru | Go Programming Bootcamp lesson | BraveProgrammer
  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 26 of 60

·Go

Logging with `log` and Structured Logging (`zap`)

15 minutes

Course progress43%

Simple Logging

This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.

The standard library log provides basic logging.

log.Println("Server started")
log.Fatalf("fatal error: %v", err)

Structured logging – zap

$ go get go.uber.org/zap
import "go.uber.org/zap"

func main() {
    logger, _ := zap.NewProduction()
    defer logger.Sync()
    sugar := logger.Sugar()
    sugar.Infow("request received", "method", "GET", "path", "/api")
}

zap offers high‑performance, leveled, and context‑aware logging.

Info

For long‑running services, prefer structured logs – they are easier to query with tools like Loki or Elastic.
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from Go Programming BootcampBrowse activities
Previous lessonTesting HTTP HandlersContinue to lesson 27Graceful Shutdown of ServersBack to Go Programming Bootcamp curriculum