|0.1.1||Oct 31, 2021|
|0.1.0||Jun 25, 2020|
|0.0.0||Jun 25, 2020|
#173 in #logging
209 downloads per month
Used in 2 crates
Thanks to Jeroen C. van Gelderen for creating the winlog project from which this is forked.
- Writes Rust log messages to the Windows event log using the RegisterEventSourceW and ReportEventW APIs.
- Provides utility functions to register/unregister your event source in the Windows registry.
- Embeds a small (120-byte) message resource library containing the necessary log message templates in your executable.
- Does not panic.
The five Rust log levels are mapped to Windows event types as follows:
|Rust Log Level||Windows Event Type||Windows Event Id|
- Rust 1.29+ on Windows with MSVC toolchain
- [Windows, optional] mc.exe and rc.exe (only required when
- [Windows, optional] PowerShell (used for the end-to-end test)
[dependencies] eventlog = "0.1.0"
Register the log source in the Windows registry:
This usually requires Administrator permission so this is usually done during installation time.
If your MSI installer (or similar) registers your event sources you should not call this.
eventlog::init("Example Log", log::Level::Trace).unwrap(); info!("Hello, Event Log"); trace!("This will be logged too");
Deregister the log source:
This is usually done during program uninstallation. If your MSI installer (or similar) deregisters your event sources you should not call this.
eventmsgs.rs are under source control so users
don't need to have
rc.exe installed for a standard build.
eventmsgs.mcwas changed then
build.rsemits linker flags so
The end-to-end test requires 'Full Control' permissions on the
- Create a unique temporary event source name (
- Register our compiled test executable as
EventMessageFilefor the event source in the Windows registry. You can see a new key at
- Write some log messages to the event source.
- Use PowerShell to retrieve the logged messages.
- Deregister our event source. This removes the
- Assert that the retrieved log messages are correct.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.