0

Folks, I've Googled, but nothing came out handy.

I want to create custom Log file using Laravel(5.1), why I want, I've multiple locations where same code will be executed, so it'll be pretty hard to visit each location and view Log file. Currently, writing stuff to default Laravel.log file, working fine, but want to create some custom abc.log file to handle all custom logs.

Thanks

1 Answer 1

2

Laravel uses the Monolog package to handle logging. You can add handlers to the Monolog instance to do all sorts of interesting things with your log messages.

In the documentation on Logging, instructions are given on how to access the underlying Monolog instance. Once you do that, you can:

  • add "Handlers" to the logger which can send messages to other logging systems, write them to the file system, send emails/SMS messages, ...

  • add "Formatters" to the logger which will reformat the message however you like (HTML, text, or a format for a particular message recipient like Gelf or Loggly)

  • add "Processors" which will add additional information to the messages, such as IP addresses, system stats, etc.

I have (in the past) implemented the GelfHandler to push messages to a Graylog server. It's pretty easy to set up. There's a good explanation over on Laracasts.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, really helped :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.