• /
  • EnglishEspañol日本語한국어Português
  • 로그인지금 시작하기

Go agent logging

New Relic for Go logging uses the standard Go log package and a New Relic Logger package. Logging is useful for troubleshooting your New Relic integration; for example, with installation or configuration problems.

Write log files

To use the Go agent methods for writing log and audit files, see log.go on the agent GitHub repo.

Logrus integration example

New Relic offers an integration for the Logrus logging system. Here is an example of using the New Relic Logrus integration in an application:

  1. Import both github.com/sirupsen/logrus and github.com/newrelic/go-agent/v3/integrations/nrlogrus.

  2. Set the log level and assign the Logger output to Logrus. For example:

    app, err := newrelic.NewApplication(
    newrelic.ConfigAppName("Your Application Name"),
    newrelic.ConfigLicense("YOUR_NEW_RELIC_LICENSE_KEY"),
    func(config *newrelic.Config) {
    logrus.SetLevel(logrus.DebugLevel)
    config.Logger = nrlogrus.StandardLogger()
    },
    )

View logs for your APM and infrastructure data

You can also bring your logs and application's data together to make troubleshooting easier and faster. With logs in context, you can see log messages related to your errors and traces directly in your app's UI. You can also see logs in context of your infrastructure data, such as Kubernetes clusters. No need to switch to another UI page.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.