Skip to content

How to disable sampling #1212

Answered by abhinav
pdorrestijn asked this question in Q&A
Discussion options

You must be logged in to vote

If you're constructing a logger like that code sample -- with zapcore.NewCore followed by zap.New,
sampling is already disabled.

To enable sampling on top of that, you'd have to use zapcore.NewSamplerWithOptions.

core = zapcore.NewSamplerWithOptions(...)

But as-is, without any additional wrapping, sampling is already disabled.

The other way you could've been constructing the logger is with zap.Config.Build(),
in which case, to disable sampling you'd have to set Config.Sampling to nil.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by alxn
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1211 on December 12, 2022 02:43.