Documentation
¶
Overview ¶
Package nrslog supports `log/slog`
Wrap your slog Logger using nrslog.Transform to send agent log messages to standard log library.
Example ¶
package main
import (
"log/slog"
"github.com/newrelic/go-agent/v3/integrations/nrslog"
"github.com/newrelic/go-agent/v3/newrelic"
)
func main() {
// Get the default logger or create a new one:
l := slog.Default()
_, err := newrelic.NewApplication(
newrelic.ConfigAppName("Example App"),
newrelic.ConfigLicense("__YOUR_NEWRELIC_LICENSE_KEY__"),
// Use nrslog to register the logger with the agent:
nrslog.ConfigLogger(l.WithGroup("newrelic")),
)
if err != nil {
panic(err)
}
}
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigLogger ¶
func ConfigLogger(l *slog.Logger) newrelic.ConfigOption
ConfigLogger configures the newrelic.Application to send log messages to the provided slog.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.