Crates.io | stashlog |
lib.rs | stashlog |
version | 0.0.13 |
source | src |
created_at | 2024-10-05 11:43:00.514614 |
updated_at | 2024-10-05 20:01:57.134506 |
description | A minimalistic Rust library for Logstash Event format logging. |
homepage | |
repository | |
max_upload_size | |
id | 1397625 |
size | 24,829 |
A minimalistic Rust library for Logstash Event format logging.
use medunes::stashlog;
fn main() {
let logger = stashlog::Logger {
config: Config {
version: 1,
app_name: "my-app".to_string(),
file_path: "/home/my-app/logs/logstash.log".to_string(),
},
};
logger.info("User Logged in");
logger.info_extra("User Logged in", &json!({"user_id": user_id}).to_string());
logger.error_extra("Maximum login attemps reached", &json!({"user_id": user_id}).to_string());
StashLog
Your rust application uses the stashlog
package to output logs to a preconfigured file path: for example here /opt/example-app/log-path/logstash.log
Filebeat
/opt/example-app/log-path/logstash.log
some-server.logstash.com:5044
#/etc/filebeat/filebeat.yml
filebeat.inputs:
- type: log
enabled: true
paths:
- /opt/example-app/log-path/logstash.log
fields:
log_type: logstash
output.logstash:
hosts: ["some-server.logstash.com:5044"]
transport: udp
ELK