Troubleshooting Guide
Common Issues
Logs Not Appearing
Problem: No log output visible
Solutions:
- Check if logger is enabled:
#![allow(unused)] fn main() { logger.enable(); }
- Verify log level:
#![allow(unused)] fn main() { let mut config = LoggerConfig::default(); config.level = Level::Trace; // Lower threshold logger.configure(config); }
- Check global display settings:
#![allow(unused)] fn main() { config.global_console_display = true; config.global_file_storage = true; }
- Verify sinks exist:
#![allow(unused)] fn main() { println!("Sinks: {}", logger.get_sink_count()); println!("IDs: {:?}", logger.list_sinks()); }
File Not Created
Problem: Log file doesn't exist
Solutions:
- Check path is correct
- Verify parent directories exist (Logly creates them automatically)
- Check file permissions
- Verify
global_file_storage = true
Rotation Not Working
Problem: Files not rotating
Solutions:
- Verify rotation configuration:
#![allow(unused)] fn main() { SinkConfig { rotation: Some("daily".to_string()), size_limit: Some(10 * 1024 * 1024), ..Default::default() } }
- Check if size/time threshold is reached
- Ensure retention policy is set
GPU Not Available
Problem: GPU acceleration fails
Solutions:
- Install CUDA toolkit
- Compile with
--features gpu - Check GPU is detected by system
- Use CPU fallback (automatic)
Performance Issues
Problem: Logging is slow
Solutions:
- Enable async writing:
#![allow(unused)] fn main() { SinkConfig { async_write: true, buffer_size: 16384, ..Default::default() } }
- Reduce log level in production:
#![allow(unused)] fn main() { config.level = Level::Info; // Skip DEBUG/TRACE }
- Use file storage instead of console
- Increase buffer sizes
Configuration File Not Loaded
Problem: logly.toml settings ignored
Solutions:
- Verify file is in project root
- Check file name is exactly
logly.toml - Validate TOML syntax
- Check for duplicate config files
- Ensure scanning is enabled (default)
Memory Usage High
Problem: High memory consumption
Solutions:
- Reduce buffer sizes:
#![allow(unused)] fn main() { config.gpu_buffer_size = 512 * 1024; // 512KB }
- Disable GPU if not needed
- Use smaller retention periods
- Enable rotation with size limits
Error Messages
"Sink not found"
Cause: Invalid sink ID
Solution: Use valid ID from add_sink() return value
"Invalid log level"
Cause: Unknown level name Solution: Use: TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, FAIL, CRITICAL
"Failed to create file"
Cause: Permission denied or invalid path Solution: Check permissions and path validity
"CUDA device not available"
Cause: No GPU or CUDA not installed Solution: Install CUDA or disable GPU feature
Debug Mode
Enable debug mode to see internal operations:
#![allow(unused)] fn main() { let mut config = LoggerConfig::default(); config.debug_mode = true; config.debug_log_file = Some(PathBuf::from("logly_debug.log")); logger.configure(config); }
Output shows:
- Sink operations
- Configuration changes
- GPU status
- Callback execution
- File operations
Reporting Issues
If you encounter a bug, please report it:
Rust crate: https://github.com/muhammad-fiaz/logly-rs/issues Python package: https://github.com/muhammad-fiaz/logly/issues
Include:
- Rust version
- Logly version
- Operating system
- Minimal reproduction code
- Error messages
- Debug log output
Performance Profiling
Profile logging performance:
#![allow(unused)] fn main() { use std::time::Instant; let start = Instant::now(); for i in 0..10000 { logger.info(format!("Message {}", i))?; } let duration = start.elapsed(); println!("10,000 logs in {:?}", duration); }
Best Practices
- Start simple: Use defaults first
- Enable debug mode: When troubleshooting
- Check examples: Reference working code
- Read docs: Check relevant guide
- Test incrementally: Add features one at a time