{"id":13439761,"url":"https://github.com/rust-lang/log","last_synced_at":"2025-05-13T18:04:55.291Z","repository":{"id":24567343,"uuid":"27974762","full_name":"rust-lang/log","owner":"rust-lang","description":"Logging implementation for Rust","archived":false,"fork":false,"pushed_at":"2025-04-02T15:10:07.000Z","size":1035,"stargazers_count":2334,"open_issues_count":11,"forks_count":264,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-05-06T17:13:52.242Z","etag":null,"topics":["logging","rust-library"],"latest_commit_sha":null,"homepage":"https://docs.rs/log","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-lang.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-12-13T21:45:04.000Z","updated_at":"2025-05-06T09:18:26.000Z","dependencies_parsed_at":"2024-11-05T18:01:39.437Z","dependency_job_id":"4ce10938-8041-4551-9395-7fa8387551e0","html_url":"https://github.com/rust-lang/log","commit_stats":{"total_commits":565,"total_committers":121,"mean_commits":4.669421487603306,"dds":0.7628318584070797,"last_synced_commit":"134d252f0599d19070fd02f93600d48254e6f91f"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Flog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Flog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Flog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Flog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-lang","download_url":"https://codeload.github.com/rust-lang/log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973690,"owners_count":21834108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logging","rust-library"],"created_at":"2024-07-31T03:01:16.888Z","updated_at":"2025-05-13T18:04:55.236Z","avatar_url":"https://github.com/rust-lang.png","language":"Rust","readme":"log\n===\n\nA Rust library providing a lightweight logging *facade*.\n\n[![Build status](https://img.shields.io/github/actions/workflow/status/rust-lang/log/main.yml?branch=master)](https://github.com/rust-lang/log/actions)\n[![Latest version](https://img.shields.io/crates/v/log.svg)](https://crates.io/crates/log)\n[![Documentation](https://docs.rs/log/badge.svg)](https://docs.rs/log)\n![License](https://img.shields.io/crates/l/log.svg)\n\n* [`log` documentation](https://docs.rs/log)\n\nA logging facade provides a single logging API that abstracts over the actual\nlogging implementation. Libraries can use the logging API provided by this\ncrate, and the consumer of those libraries can choose the logging\nimplementation that is most suitable for its use case.\n\n\n## Minimum supported `rustc`\n\n`1.61.0+`\n\nThis version is explicitly tested in CI and may be bumped in any release as needed. Maintaining compatibility with older compilers is a priority though, so the bar for bumping the minimum supported version is set very high. Any changes to the supported minimum version will be called out in the release notes.\n\n## Usage\n\n### In libraries\n\nLibraries should link only to the `log` crate, and use the provided macros to\nlog whatever information will be useful to downstream consumers:\n\n```toml\n[dependencies]\nlog = \"0.4\"\n```\n\n```rust\nuse log::{info, trace, warn};\n\npub fn shave_the_yak(yak: \u0026mut Yak) {\n    trace!(\"Commencing yak shaving\");\n\n    loop {\n        match find_a_razor() {\n            Ok(razor) =\u003e {\n                info!(\"Razor located: {razor}\");\n                yak.shave(razor);\n                break;\n            }\n            Err(err) =\u003e {\n                warn!(\"Unable to locate a razor: {err}, retrying\");\n            }\n        }\n    }\n}\n```\n\n### In executables\n\nIn order to produce log output, executables have to use a logger implementation compatible with the facade.\nThere are many available implementations to choose from, here are some options:\n\n* Simple minimal loggers:\n    * [`env_logger`](https://docs.rs/env_logger/*/env_logger/)\n    * [`colog`](https://docs.rs/colog/*/colog/)\n    * [`simple_logger`](https://docs.rs/simple_logger/*/simple_logger/)\n    * [`simplelog`](https://docs.rs/simplelog/*/simplelog/)\n    * [`pretty_env_logger`](https://docs.rs/pretty_env_logger/*/pretty_env_logger/)\n    * [`stderrlog`](https://docs.rs/stderrlog/*/stderrlog/)\n    * [`flexi_logger`](https://docs.rs/flexi_logger/*/flexi_logger/)\n    * [`call_logger`](https://docs.rs/call_logger/*/call_logger/)\n    * [`std-logger`](https://docs.rs/std-logger/*/std_logger/)\n    * [`structured-logger`](https://docs.rs/structured-logger/latest/structured_logger/)\n    * [`clang_log`](https://docs.rs/clang_log/latest/clang_log)\n    * [`ftail`](https://docs.rs/ftail/latest/ftail/)\n* Complex configurable frameworks:\n    * [`log4rs`](https://docs.rs/log4rs/*/log4rs/)\n    * [`logforth`](https://docs.rs/logforth/*/logforth/)\n    * [`fern`](https://docs.rs/fern/*/fern/)\n    * [`spdlog-rs`](https://docs.rs/spdlog-rs/*/spdlog/)\n* Adaptors for other facilities:\n    * [`syslog`](https://docs.rs/syslog/*/syslog/)\n    * [`systemd-journal-logger`](https://docs.rs/systemd-journal-logger/*/systemd_journal_logger/)\n    * [`slog-stdlog`](https://docs.rs/slog-stdlog/*/slog_stdlog/)\n    * [`android_log`](https://docs.rs/android_log/*/android_log/)\n    * [`win_dbg_logger`](https://docs.rs/win_dbg_logger/*/win_dbg_logger/)\n    * [`db_logger`](https://docs.rs/db_logger/*/db_logger/)\n    * [`log-to-defmt`](https://docs.rs/log-to-defmt/*/log_to_defmt/)\n    * [`logcontrol-log`](https://docs.rs/logcontrol-log/*/logcontrol_log/)\n* For WebAssembly binaries:\n    * [`console_log`](https://docs.rs/console_log/*/console_log/)\n* For dynamic libraries:\n    * You may need to construct [an FFI-safe wrapper over `log`](https://github.com/rust-lang/log/issues/421) to initialize in your libraries.\n* Utilities:\n    * [`log_err`](https://docs.rs/log_err/*/log_err/)\n    * [`log-reload`](https://docs.rs/log-reload/*/log_reload/)\n    * [`alterable_logger`](https://docs.rs/alterable_logger/*/alterable_logger)\n\nExecutables should choose a logger implementation and initialize it early in the\nruntime of the program. Logger implementations will typically include a\nfunction to do this. Any log messages generated before the logger is\ninitialized will be ignored.\n\nThe executable itself may use the `log` crate to log as well.\n\n## Structured logging\n\nIf you enable the `kv` feature, you can associate structured data with your log records:\n\n```rust\nuse log::{info, trace, warn};\n\npub fn shave_the_yak(yak: \u0026mut Yak) {\n    // `yak:serde` will capture `yak` using its `serde::Serialize` impl\n    //\n    // You could also use `:?` for `Debug`, or `:%` for `Display`. For a\n    // full list, see the `log` crate documentation\n    trace!(target = \"yak_events\", yak:serde; \"Commencing yak shaving\");\n\n    loop {\n        match find_a_razor() {\n            Ok(razor) =\u003e {\n                info!(razor; \"Razor located\");\n                yak.shave(razor);\n                break;\n            }\n            Err(e) =\u003e {\n                // `e:err` will capture `e` using its `std::error::Error` impl\n                warn!(e:err; \"Unable to locate a razor, retrying\");\n            }\n        }\n    }\n}\n```\n","funding_links":[],"categories":["Libraries","Rust","库 Libraries","tools","虚拟化"],"sub_categories":["Logging","日志记录 Logging","日志"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-lang%2Flog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-lang%2Flog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-lang%2Flog/lists"}