Star us on GitHub

Logging in Go / Fiber

Learn how to set up Go log ingestion with fiber.
Set up your frontend integration.

First, make sure you've followed the frontend getting started guide.

Call logrus methods while passing the request context.

The request context allows highlight to associate logs with the incoming frontend session and network request.

logrus.WithContext(c.Context()).WithField("user", "bob").Infof("hello, %s!", "world")
Call the Highlight logging SDK.

Use our SDK to configure logrus, and use it as normal.

package main import ( "context" "" "" "" ) func main() { // setup the highlight SDK highlight.SetProjectID("<YOUR_PROJECT_ID>") highlight.Start( highlight.WithServiceName("my-fiber-app"), highlight.WithServiceVersion("git-sha"), ) defer highlight.Stop() // setup highlight logrus hook hlog.Init() // if you don't want to get stdout / stderr output, add the following uncommented // hlog.DisableOutput() app := fiber.New() app.Use(logger.New()) // setup go fiber to use the highlight middleware for header parsing app.Use(highlightFiber.Middleware()) app.Get("/", func(c *fiber.Ctx) error { // in handlers, use logrus with the UserContext to associate logs with the frontend session. logrus.WithContext(c.Context()).Infof("hello from") return c.SendString("Hello, World!") }) logrus.Fatal(app.Listen(":3456")) }
Verify your backend logs are being recorded.

Visit the highlight logs portal and check that backend logs are coming in.