1 个不稳定版本
0.1.0 | 2021年9月15日 |
---|
#335 in FFI
15KB
207 代码行
log4j-rs
此crate允许Rust开发者轻松地从Rust记录到Java的Log4j。
用法
use log4j::{JavaLogger, LogLevel};
// Create a logger
// This assumes that com.example.Example has an appender in the Java log4j configuration.
// `&env` is a reference to jni::JNIENv
let logger = JavaLogger::new(&env, "com.example.Example").expect("Failed to create JavaLogger");
// Now for the actual logging
logger.log(LogLevel::Error, "Error!").expect("Failed to log to ERROR level");
logger.log(LogLevel::Warn, "Warn!").expect("Failed to log to WARN level");
logger.log(LogLevel::Info, "Info!").expect("Failed to log to INFO level");
logger.log(LogLevel::Debug, "Debug!").expect("Failed to log to DEBUG level");
许可
log4j-rs
依据您的选择,在Apache-2.0和MIT许可下双许可
依赖
~1.4–2.8MB
~47K SLoC