Skip to content
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

Support for multiple Request Loggers #2219

Open
LoonyRules opened this issue Apr 7, 2024 · 4 comments
Open

Support for multiple Request Loggers #2219

LoonyRules opened this issue Apr 7, 2024 · 4 comments

Comments

@LoonyRules
Copy link
Contributor

Describe the feature
It would be great if we could register multiple Request Loggers, just like we do right now for registering .beforeMatched(...) handlers.
This would allows us to separate logging into specific domain classes and also helps with unit tests, for example:

  • AuditRequestLogger: Logs the HTTP and WebSocket requests and via Logback, streams these to Logstash (eg: for Kibana usage).
  • MetricRequestLogger: Logs the HTTP and WebSocket requests via their matchedPath()'s for tracking Metrics.

Additional context
I think the current way of registering request loggers is perfectly fine, and that under-the-hood, Javalin should just use a collection of request loggers that it executes in order. When doing this, if 1 Request Logger throws an exception, the other Request Loggers should still be invoked.

@zugazagoitia
Copy link
Member

What would be the advantage of handing this in Javalin's side over doing the same in user code? Should be simple enough to aggregate loggers on your side, if it were the case.

@tipsy
Copy link
Member

tipsy commented Apr 8, 2024

As @zugazagoitia points out, this does seem very solvable - is there something we're not seeing @LoonyRules ?

@LoonyRules
Copy link
Contributor Author

Just a nicer developer experience really, nothing more than that. For example, I've had to implement a similar thing twice already, whereas I wouldn't have to if it was just supported out of the box.

Happy for it to be rejected if you feel like it's too out of scope.

@tipsy
Copy link
Member

tipsy commented Apr 9, 2024

Super easy to implement on our side too 🤔

Let's keep it open for a while and see if we come up with any reason to not do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants