If so how can it be done? By default L4 writes to a text file. I notice that Monolog can Log to Database on its github page.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
As I had the same demand in my project, I have created a handler for Monolog to write the log output to MySQL. It is released under MIT license and available through composer or directly on GitHub. Might by worth a try.
As you can see if you read further the headline, Monolog natively supports writing to Redis, MongoDB and CouchDB. Those three are all supporting fairly write heavy (and very write heavy in the case of Redis) use-cases. MySQL is not there because logging to MySQL isn't really the best idea in the world.
If you really want to do it though, you can check the docs on creating your own handler, which explains how to create and use a PDO handler to write to a SQL database: https://github.com/Seldaek/monolog/blob/master/doc/extending.md - I still think it's a bad idea, but maybe the use case warrants it.
In laravel 5 now it is
illuminate.log
Now it will be like
Yep, You could create a listener to log everything in the routes.php
Or alternatively if you wanted to only log errors 400 and 500 Larvavel there is a Log event in the Routes.php file which listens to errors 404 and 500, you can write your own code in this event listener. So assuming you have a Model called Log defined,