loggingrustmeilisearch

Where is the output of debug!() calls in Meilisearch?


Trying to understand an open source project and I have seen the following code in many places

debug!("called with params: {:?}", body); // or some parameter instead of bo

when I run cargo run I do not see any of these outputs in the console. only the INFO logs are displayed

[2022-12-19T13:53:23Z INFO  actix_server::builder] Starting 8 workers
[2022-12-19T13:53:23Z INFO  actix_server::server] Actix runtime found; starting in Actix runtime
[2022-12-19T14:00:58Z INFO  actix_web::middleware::logger] ::1 "GET /stats HTTP/1.1" 200 49 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" 0.009129
[2022-12-

I tried running RUST_LOG=debug cargo run. but still unable to see the debug output. as I can see the logging is configured via rust-log crate. but with my limited experience with rust I couldn't figure out more. I assume these debug logs are in some file but not sure exactly where they are.


Solution

  • meilisearch provides a command line option --log-level=... for users to specify the log level, which can contain any filter string that's accepted by the env_logger crate. To enable all the log::debug! outputs, supply --log-level=debug when running the binary.

    # If building from source
    cargo run -- --log-level=debug
    
    # If installed
    meilisearch --log-level=debug
    

    See the documentation of env_logger for the syntax of filter strings.