| Crates.io | log4rs-tcp |
| lib.rs | log4rs-tcp |
| version | 0.1.3 |
| created_at | 2025-04-29 11:55:38.549642+00 |
| updated_at | 2025-04-29 12:28:38.393274+00 |
| description | Tcp Appender for log4rs |
| homepage | |
| repository | https://github.com/cybrlab-ai/log4rs-tcp |
| max_upload_size | |
| id | 1653456 |
| size | 32,030 |
WARNING: This crate is currently in early development (v0.1.0) and NOT READY FOR PRODUCTION USE.
- The API may change without notice
- Error handling needs improvement
- Performance optimizations are still being implemented
- Debug statements are present in the code
- Comprehensive testing is not yet complete
We welcome feedback and contributions as we work toward a stable release.
log4rs-tcp provides a TCP appender for the log4rs logging framework. It allows log messages to be sent to a remote TCP server with configurable connection handling, buffering, and automatic reconnection capabilities.
Add this to your Cargo.toml:
[dependencies]
log4rs = "1.3.0"
log = "0.4.26"
use log::{info, LevelFilter};
use log4rs::append::console::ConsoleAppender;
use log4rs::config::{Appender, Config, Root};
use log4rs::encode::pattern::PatternEncoder;
use log4rs_tcp::TcpAppender;
use std::time::Duration;
fn main() {
// Create a TCP appender
let tcp = TcpAppender::builder()
.encoder(Box::new(PatternEncoder::new("{d} - {m}{n}")))
.timeout(Duration::from_secs(5))
.buffer_len(100)
.build("127.0.0.1:9000")
.unwrap();
// Create a basic console appender as backup
let console = ConsoleAppender::builder().build();
// Build the log4rs config with both appenders
let config = Config::builder()
.appender(Appender::builder().build("tcp", Box::new(tcp)))
.appender(Appender::builder().build("console", Box::new(console)))
.build(Root::builder()
.appender("tcp")
.appender("console")
.build(LevelFilter::Info))
.unwrap();
// Initialize the logger
log4rs::init_config(config).unwrap();
// Send some log messages
info!("This message will be sent to the TCP server!");
}
This project is in active development. Here's what's working and what's still in progress:
Contributions are welcome! Please feel free to submit a Pull Request.
log4rs-tcp is licensed under the MIT License.