Structural logging

I believe the logging is the silver bullet of debugging, because it works everywhere—on tests, on production servers, in cloud infrastructure. Also, you don't have to reproduce the activity that produces bugs – you can take the logs of a working application and read them to detect problems. Sometimes, you will have bugs that you can't reproduce, and logs can help to fix them.

We already studied the basics of logging in Chapter 3, Logging and Configuring Microservices. We used the simple env_logger and log crates, but for large applications, it may not be enough, because you will need to collect all logs for analyzing, and it's simpler to parse logs from a formal format like JSON. There are structural logging crates for this case. Let's explore a tiny example of using structural logging with the slog crate.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.245.1