Skip to content

Suppressing redundant logging  #1592

Closed
Closed
@azw413

Description

@azw413

Rocket is mostly amazing but there's a lot of redundant logging coming out which can't be suppressed. Documentation suggests that setting config.log_level(LoggingLevel::Off) should disable internal logging but it doesn't. Here's an example :-

2021-03-26 15:48:52 [INFO] [rocket::rocket] GET /api/roid/list/5305 text/xml:
2021-03-26 15:48:52 [INFO] [_] Matched: GET /api/roid/list/<sector_id> (api_roid_list)
2021-03-26 15:48:52 [INFO] [vo_server] 209.240.117.223:54991 -> /api/roid/list/5305: Azek I-12 - 240 asteroids.
2021-03-26 15:48:52 [INFO] [_] Outcome: Success
2021-03-26 15:48:52 [INFO] [_] Response succeeded.
2021-03-26 15:49:11 [INFO] [rocket::rocket] HEAD / text/html:
2021-03-26 15:49:11 [ERROR] [_] No matching routes for HEAD / text/html.
2021-03-26 15:49:11 [INFO] [_] Autohandling HEAD request.
2021-03-26 15:49:11 [INFO] [_] Matched: GET / [10]
2021-03-26 15:49:11 [INFO] [_] Outcome: Success
2021-03-26 15:49:11 [INFO] [_] Response succeeded.

Note all of the output when all I want is the vo_server output. Here's my initialisation :-

// Setup logging
   fern::Dispatch::new()
      .format(|out, message, record| {
         out.finish(format_args!(
            "{} [{}] [{}] {}",
            chrono::Local::now().format("%Y-%m-%d %H:%M:%S"),
            record.level(),
            record.target(),
            message
         ))
      })
      .level(log::LevelFilter::Info)
      .chain(std::io::stdout())
      .chain(fern::log_file("vo-server.log").unwrap())
      .apply().expect("Can't initialise logging");

   load_sectors().expect("Can't read sectors database");

   let mut config = Config::build(Environment::Production)
      .address("0.0.0.0")
      .port(3000)
      .log_level(LoggingLevel::Off)
      .finalize();
   rocket::custom(config.unwrap())
      .mount("/", routes![api_stats, api_roid_list, api_roid_query, api_roid_add, api_roid_table])
      .mount("/", StaticFiles::from("html"))
      .launch();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions