Skip to content

Commit

Permalink
Add Example for Multiple Outputs using Multiwriter (#198)
Browse files Browse the repository at this point in the history
Fixes #73
  • Loading branch information
muya committed May 28, 2020
1 parent f83de79 commit 63767a5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Expand Up @@ -469,6 +469,25 @@ if err := http.ListenAndServe(":8080", nil); err != nil {
}
```

## Multiple Log Output
`zerolog.MultiLevelWriter` may be used to send the log message to multiple outputs.
In this example, we send the log message to both `os.Stdout` and the in-built ConsoleWriter.
```go
func main() {
consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout}

multi := zerolog.MultiLevelWriter(consoleWriter, os.Stdout)

logger := zerolog.New(multi).With().Timestamp().Logger()

logger.Info().Msg("Hello World!")
}

// Output (Line 1: Console; Line 2: Stdout)
// 12:36PM INF Hello World!
// {"level":"info","time":"2019-11-07T12:36:38+03:00","message":"Hello World!"}
```

## Global Settings

Some settings can be changed and will by applied to all loggers:
Expand Down

0 comments on commit 63767a5

Please sign in to comment.