> ## Documentation Index
> Fetch the complete documentation index at: https://docs.restate.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Logging

> Configure the log level of your services.

The Go SDK uses the standard library [`log/slog`](https://pkg.go.dev/log/slog)
package for logging.

By default logs will go to the slog default handler. However, you may provide
any slog handler upon creating the Restate server instance, which allows you to
direct the logs to other log libraries:

```go {"CODE_LOAD::go/develop/logging.go#handler"}  theme={null}
myHandler := slog.NewJSONHandler(os.Stdout, nil)
server.NewRestate().
  WithLogger(myHandler, true).
  Bind(restate.Reflect(Monitoring{})).
  Start(context.Background(), "0.0.0.0:9080")
```

**Avoiding duplicate logging**

If you use the default slog logger or another logger, log statements will be
printed over and over again during replays.
To avoid this, you can use the Restate context logger, which is a
`*slog.Logger` that suppresses duplicate log statements during replays:

```go {"CODE_LOAD::go/develop/logging.go#logger"}  theme={null}
ctx.Log().Info("This will not be printed again during replays")
ctx.Log().Debug("This will not be printed again during replays")
```

When providing a custom log handler using
[`WithLogger`](https://pkg.go.dev/github.com/restatedev/sdk-go/server#Restate.WithLogger),
you can provide `false` as the second argument, in which case logs will not be
dropped during replay allowing you to handle them as you prefer. You can still
determine whether they would have been dropped using
[`rcontext.LogContextFrom`](https://pkg.go.dev/github.com/restatedev/sdk-go/rcontext#LogContextFrom)
on the context passed to your log handler.
