Usage
Learn how to use Logixlysia in your Elysia applications.
Installation
Logixlysia is available as an npm package. You can install it using Bun:
Basic Usage
After installing Logixlysia, you can import and use it in your Elysia application:
Configuration Options
Logixlysia provides various configuration options to customize your logging experience:
Basic Configuration
Custom Log Format
You can customize the log message format using placeholders:
Available placeholders:
{now}
- Current date and time{level}
- Log level (INFO, WARNING, ERROR){duration}
- Request duration in milliseconds{method}
- HTTP method{pathname}
- Request path{status}
- Response status code{message}
- Custom message{ip}
- Client IP address{epoch}
- Unix timestamp
Log Filtering
Filter logs based on level, status, or method:
Advanced Usage
Custom Log Handlers
You can extend Logixlysia by creating custom loggers:
Error Handling
Logixlysia automatically captures and logs errors:
This will automatically log the error with stack trace and request details.
Best Practices
-
Log Levels
- Use appropriate log levels (INFO, WARNING, ERROR)
- Avoid excessive logging in production
-
Performance
- Use log filtering in production
- Consider using file logging for important events
-
Security
- Be careful with logging sensitive information
- Use log filtering to exclude sensitive routes
Examples
Basic API with Logging
Custom Error Handling
Need Help?
If you have any questions or need help, feel free to open an issue on our GitHub repository or join our community on Discord.