Skip to content
Snippets Groups Projects
Select Git revision
  • feaebaa19382185c1935f416532b95baf20d3822
  • master default protected
  • 0.5.9
  • 0.5.8
  • 0.5.7
  • 0.5.6
  • 0.5.5
  • 0.5.4
  • 0.5.3
  • 0.5.2
  • 0.5.1
  • 0.5.0
  • 0.4.17
  • 0.4.16
  • 0.4.15
  • 0.4.14
  • 0.4.13
  • 0.4.12
  • 0.4.11
  • 0.4.10
  • 0.4.9
  • 0.4.8
22 results

flake-profile-8-link

Blame
  • FAQ.md 6.47 KiB

    Frequently Asked Questions

    Design

    Why spend so much effort on logger performance?

    Of course, most applications won't notice the impact of a slow logger: they already take tens or hundreds of milliseconds for each operation, so an extra millisecond doesn't matter.

    On the other hand, why not make structured logging fast? The SugaredLogger isn't any harder to use than other logging packages, and the Logger makes structured logging possible in performance-sensitive contexts. Across a fleet of Go microservices, making each application even slightly more efficient adds up quickly.

    Why aren't Logger and SugaredLogger interfaces?

    Unlike the familiar io.Writer and http.Handler, Logger and SugaredLogger interfaces would include many methods. As Rob Pike points out, "The bigger the interface, the weaker the abstraction." Interfaces are also rigid — any change requires releasing a new major version, since it breaks all third-party implementations.

    Making the Logger and SugaredLogger concrete types doesn't sacrifice much abstraction, and it lets us add methods without introducing breaking changes. Your applications should define and depend upon an interface that includes just the methods you use.

    Why are some of my logs missing?

    Logs are dropped intentionally by zap when sampling is enabled. The production configuration (as returned by NewProductionConfig() enables sampling which will cause repeated logs within a second to be sampled. See more details on why sampling is enabled in Why sample application logs.