Crates.io | log4j |
lib.rs | log4j |
version | 0.1.0 |
source | src |
created_at | 2021-09-15 09:21:16.248647 |
updated_at | 2021-09-15 09:21:16.248647 |
description | Library to log to Java's log4j from Rust |
homepage | https://github.com/Better-Player/log4j-rs |
repository | https://github.com/Better-Player/log4j-rs |
max_upload_size | |
id | 451717 |
size | 16,049 |
This crate allows a Rust developer to easily log to Java's Log4j from Rust.
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
is dual licensed under the Apache-2.0 and MIT license, at your discretion