Overview
The Mangopay PHP SDK supports PSR-3 compliant logging, allowing you to integrate with any logging library that implements thePsr\Log\LoggerInterface. This enables you to track API calls, debug issues, and monitor your integration’s behavior.
PSR-3 Compliance
The SDK uses the PSR-3 Logger Interface standard, which means you can use popular logging libraries like:- Monolog
- KLogger
- Analog
- Any PSR-3 compliant logger
Setting Up Monolog
Monolog is the most popular PHP logging library and works seamlessly with the SDK:Installation
Basic Configuration
Log Levels
Configure different log levels based on your environment:Multiple Handlers
Use multiple handlers to route logs to different destinations:Formatting Logs
Customize log output format:Logging to Syslog
Log to system log for centralized monitoring:Email Notifications for Errors
Receive email alerts for critical errors:Logging in Symfony
Integrate with Symfony’s logging system:services.yaml:
Logging in Laravel
Use Laravel’s built-in logging:config/logging.php:
Custom Logger Implementation
Create a custom logger for specific needs:What Gets Logged
The SDK logs various events including:- API requests and responses
- Authentication token generation
- Error messages and exceptions
- Rate limit information
- Network timeouts
Filtering Sensitive Data
Ensure sensitive data is not logged:Environment-Based Configuration
Adjust logging based on environment:Best Practices
Use Appropriate Levels
Use DEBUG for development, INFO for production, and ERROR for critical issues.
Rotate Log Files
Implement log rotation to prevent disk space issues.
Protect Sensitive Data
Never log card numbers, CVV codes, or API credentials.
Monitor Logs
Set up alerts for error patterns and unusual activity.
Troubleshooting
Common logging issues and solutions:Logs Not Appearing
Testing Logger Configuration
Related Resources
Monolog Documentation
Official Monolog documentation
PSR-3 Standard
PSR-3 Logger Interface specification