-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE REQUEST] Support log/slog #2260
Comments
Hello @trungdlp-wolffun, upgrade Iris with package main
import (
"log/slog"
"os"
"github.com/kataras/iris/v12"
)
func main() {
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}))
app := iris.New()
app.Logger().Install(logger)
// OR: app.Logger().Install(slog.Default())
} Please post below if this is not suitable for your case. |
This code does not work |
Hello @lilili87222, what do you mean it doesn't work? I am able to verify it and it seems to be working, can you post me a full example to re-produce the issue please? Thanks a lot! package main
import (
"log/slog"
"os"
"github.com/kataras/iris/v12"
)
func main() {
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}))
app := iris.New()
app.Logger().Install(logger)
// OR: app.Logger().Install(slog.Default())
app.Get("/", func(ctx iris.Context) {
ctx.Application().Logger().Infof("Request for path: %s", ctx.Path())
})
app.Listen(":8080")
} |
This is because i was using go 1.9 witch doesn't has slog api |
No description provided.
The text was updated successfully, but these errors were encountered: