Log monitoring with papertrail in Laravel
A simpler way of logging
App developers or system administrators need to keep track and monitor all the behavior that is happening in their application or server. Logging plays a vital role in debugging existing / future bugs. Sometimes managing those logs is troublesome when the application becomes huge with thousands of users. Hence papertrail is one solution for easy log management. Papertrail manages logs seamlessly from apps, servers, and cloud services. It provides a smooth and intuitive user interface and contains charts and analytics exports along with monitoring webhooks. Some key features are listed below.
- All app logs, text log files, and Syslog in one place.
- Real-time log with pause, search, infinite scroll, alerts, and clickable log elements.
- Logs bookmarking for future reference.
- Less technical staff can view logs without any SSH/RDP knowledge or access.
- Search hours of logs typically in seconds and jump to a specific time.
- Log Velocity Analytics provides a quick visualization of log throughput for new or saved searches. It helps identify patterns or anomalies, further reducing the time to troubleshoot errors. Papertrail aggregates Syslog, Routers & firewalls, Text log files, Ruby on Rails, MySQL, Windows events, Cloud hosting, Tomcat, Apache, Heroku apps, and so on.
Papertrail with Laravel
Laravel has inbuilt support for papertrail. After setting up your account copy necessary information fromPapertrail Log destination and use them in your .env file. Also, do not forget to change LOG_CHANNEL to papertrail.
LOG_CHANNEL=papertrail PAPERTRAIL_URL=yourdestination.papertrailapp.com PAPERTRAIL_PORT=yourport
Now you can simply view the log in your papertrail dashboard. Yes. it is as simple as that.
Papertrail allows you to search for log content and also save those search query strings. You can trigger an alert event that matches one of your saved searches then notify your email or send directly to services like Slack, Librato, PagerDuty, Campfire, and your own custom HTTP webhooks. This is a great feature to monitor unexpected exception that occurs in a rare case and hard to handle.
How to create an alert
- Search for query and click on Save Search:
- Give a relevant name and click Save & Setup an Alert
- Choose the alert service and configure it. You can choose your favorable option to notify. Such as email, slack, campfire, webhook.
Now you will be able to get a notification once the saved search is matched and you can perform related actions.
ConclusionPapertrail is a great tool for developers and engineers to monitor live happenings for apps and servers.