Actix and logging of JSON

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

  1. log JSON objects of the form I want, and
  2. 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.

tracing tries to be compatible with log so you could probably use tracing_subscriber (instead of env_logger) which has pretty good json logging and examples of it.

Thanks, that looks really nice actually!