create log file on external server-Laravel
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
Answer
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.
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?