AdamEsterle's avatar

To log or not to log?

When and what should I be logging?

There are several types (critical, alert, etc), but why/when/what do I need to log when I have something like BugSnag that is going to catch any errors?

0 likes
2 replies
afrayedknot's avatar

Laravel will automatically log the standard exceptions and errors within your application - so you dont need to worry about that.

What else you want/need to log is entirely dependent on your application and your needs.

  • Perhaps you have a new section of code, you might log if an exception occurs there.
  • Perhaps you have a 3rd party API call - you might log if Guzzle fails to connect.
  • Perhaps you have a payment system - you might log if you cannot connect to Stripe.

The list is endless. Just pick what you need to know (or want to know) and take it from there.

My only personal tip is: dont log just for the sake of logging. If your logs are constantly full of data you dont need, you'll stop looking at them. Keeping the logs for important information ensures you can act on it when needed.

codeNfold's avatar

To me, apart from laravel doing its logging, I love to create my own log. This helps me know details I won't ordinarily want to have in the database but yet would like to see as my code run even in production environment.

Please or to participate in this conversation.