🤗 [Question]: How to disable logger middleware in some endpoints
pablodz opened this issue · comments
Pablo commented
Question Description
I want to avoid this on my logs on k8s, i want to disable logs on "/health" or "/"
20:01:07 | 200 | 1.098µs | 192.168.57.94 | GET | /health | -
20:01:07 | 200 | 1.153µs | 192.168.23.222 | GET | /health | -
20:01:22 | 200 | 1.497µs | 192.168.57.94 | GET | /health | -
20:01:23 | 200 | 1.205µs | 192.168.23.222 | GET | /health | -
20:01:37 | 200 | 1.28µs | 192.168.57.94 | GET | /health | -
20:01:38 | 200 | 1.971µs | 192.168.23.222 | GET | /health | -
20:01:52 | 200 | 1.701µs | 192.168.57.94 | GET | /health | -
20:01:52 | 200 | 1.188µs | 192.168.23.222 | GET | /health | -
20:02:07 | 200 | 956ns | 192.168.57.94 | GET | /health | -
20:02:07 | 200 | 1.205µs | 192.168.23.222 | GET | /health | -
20:02:22 | 200 | 1.139µs | 192.168.57.94 | GET | /health | -
20:02:22 | 200 | 2.047µs | 192.168.23.222 | GET | /health | -
20:02:37 | 200 | 1.402µs | 192.168.57.94 | GET | /health | -
20:02:37 | 200 | 1.327µs | 192.168.23.222 | GET | /health | -
related:
Code Snippet (optional)
package main
import "github.com/gofiber/fiber/v3"
import "log"
func main() {
app := fiber.New()
// An example to describe the question
app.Use(logger.New())
log.Fatal(app.Listen(":3000"))
}
Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my questions prior to opening this one.
- I understand that improperly formatted questions may be closed without explanation.
welcome commented
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
Juan Calderon-Perez commented
@pablodz There's a tip about this on the documentation. The order of middlewares matters https://docs.gofiber.io/api/middleware/logger#examples
Basically app.Use(logger.New())
has to be after you define the "/health" and "/" routes