From 080ca65fb5a85b6f2b42053b9a895d462ed0ddff Mon Sep 17 00:00:00 2001 From: Simon Eskildsen Date: Mon, 6 Feb 2017 19:56:22 -0500 Subject: [PATCH] readme: add section on overriding stdlib logger --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index a404823..0671464 100644 --- a/README.md +++ b/README.md @@ -384,6 +384,18 @@ srv := http.Server{ Each line written to that writer will be printed the usual way, using formatters and hooks. The level for those entries is `info`. +This means that we can override the standard library logger easily: + +``` +logger := logrus.New() +logger.Formatter = &logrus.JSONFormatter{} + +// Use logrus for standard log output +// Note that `log` here references stdlib's log +// Not logrus imported under the name `log`. +log.SetOutput(logger.Writer()) +`` + #### Rotation Log rotation is not provided with Logrus. Log rotation should be done by an