Using the Logger
Complete guide to using the Logger class for plugin logging. Learn about all log levels, configuration options, multiline support, and best practices for logging in your plugins.
Table of Contents
Overview
Getting Started
Using the Default zAPI Logger
Creating a Custom Logger for Your Plugin
Constructor Options
Log Levels
info() - General Information
warn() - Warning Messages
error() - Error Messages
debug() - Debug Information
trace() - Trace Information
Configuration
Setting a Custom Prefix
Getting the Current Prefix
Debug Mode
Advanced Features
Multiline Messages
Using MiniMessage Formatting
Exception Logging with Debug Mode
Conditional Logging
Best Practices
1. Use Appropriate Log Levels
2. Create a Logger Manager
3. Use Debug Mode Appropriately
4. Include Context in Messages
5. Don't Log Sensitive Information
6. Use Exceptions Properly
7. Avoid Excessive Logging
8. Structure Messages Consistently
Complete Examples
Example 1: Plugin Initialization with Detailed Logging
Example 2: Feature Manager with Logging
Example 3: Configuration Validator with Detailed Logging
Common Patterns
Pattern 1: Startup Sequence
Pattern 2: Error Recovery
Pattern 3: Performance Monitoring
See Also
Last updated
Was this helpful?
