Overview
Application Logs
View and manage application logs
Performance Monitoring
Track system performance metrics
User Activity
Monitor user actions and usage
Error Tracking
Track and debug errors
Application Logs
LibreChat uses Winston for structured logging.Log Locations
Logs are stored in thelogs/ directory:
logs/app.log- General application logslogs/error.log- Error logs onlylogs/debug.log- Debug-level logs (if enabled)logs/moderation.log- Content moderation eventslogs/meili.log- Meilisearch sync logs
Log Levels
Configure logging level with environment variables:Logging level:
error, warn, info, http, verbose, debug, sillyEnable debug-level logging
Output debug logs to console
Example Configuration
.env
Viewing Logs
- Docker
- Local
- PM2
View live logs:View last 100 lines:View logs from specific time:
Log Rotation
LibreChat useswinston-daily-rotate-file for automatic log rotation:
Performance Monitoring
System Metrics
Monitor key performance indicators:Response Times
Memory Usage
Monitor Node.js memory:chrome://inspect to analyze:
- Heap snapshots
- Memory allocation
- Memory leaks
Database Performance
Monitor MongoDB performance:Meilisearch Monitoring
Monitor search index health:User Activity
Track user actions and usage patterns.User Statistics
View statistics for a specific user:- Total conversations
- Messages sent
- Tokens used
- Files uploaded
- Agents created
- Last login
- Registration date
Activity Logs
Important user actions are logged:Usage Analytics
Query MongoDB for usage insights:Most Active Users
Most Active Users
Popular Models
Popular Models
Daily Message Volume
Daily Message Volume
Error Tracking
Error Logs
All errors are logged tologs/error.log:
Common Error Patterns
Monitor for these common issues:API Rate Limits
API Rate Limits
- Implement request queuing
- Add API key rotation
- Use rate limiting middleware
Database Connection Issues
Database Connection Issues
- Check MongoDB is running
- Verify connection string
- Increase connection pool size
Memory Issues
Memory Issues
- Increase Node.js memory limit
- Optimize queries
- Implement pagination
Debugging Tools
- Node.js Inspector
- Debug Logging
- Request Logging
Start with debugging enabled:Connect Chrome DevTools:
- Open
chrome://inspect - Click “inspect” under Remote Target
- Set breakpoints and debug
Health Checks
Implement health check endpoints for monitoring:Application Health
Database Health
Search Health
Monitoring Tools Integration
Prometheus
Expose metrics for Prometheus:api/server/middleware/metrics.js
Grafana Dashboards
Create dashboards for:- Request rates and latencies
- Error rates
- Database query performance
- Memory and CPU usage
- User activity
Best Practices
Use Appropriate Log Levels
- Production:
warnorerror - Development:
debugorinfo - Troubleshooting:
verboseorsilly
Troubleshooting
Logs filling up disk space
Logs filling up disk space
- Enable log rotation
- Reduce log level in production
- Archive or delete old logs
- Use external log aggregation
Missing log entries
Missing log entries
- Check log level configuration
- Verify write permissions on logs directory
- Ensure logger is properly configured
- Check disk space availability
Cannot access logs in Docker
Cannot access logs in Docker
- Use
docker logscommand - Mount logs directory as volume
- Configure Docker logging driver
Related Documentation
- Configuration - Logging configuration
- Deployment - Production deployment
- User Management - User statistics and management