I've very limited experience with Rust and I'm trying it out for possible use at work. For that I'm writing a small web service (HTTP+ JSON) and after looking around a little I settled on actix for the HTTP bits. So far it's been a pleasure to work with. However when trying to add logging similar to what we do in other services I've run into some things I can't easily find solutions to.
AFAIU actix uses the log
crate itself, so I probably want to use an implementation that works with it. I started with env_logger
but I'm failing to make it
- log JSON objects of the form I want, and
- handle a custom field,
X-Correlation-ID
, which is received in each request and should be included in every object logged while processing that request
I had a look at json_env_logger
(as a new user I can only include two links, but it's easily found at crates-dot-io) and it looks straight forward enough that I can use it as a base for the first point above. However, the second point is something I don't really know how to accomplish.
Any suggestions and/or pointers to useful crates would be very much appreciated.