Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Laravel 4 log to a MySQL database?

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.

like image 698
Nyxynyx Avatar asked Mar 23 '13 22:03

Nyxynyx


People also ask

Which DB to use with Laravel?

Laravel makes interacting with databases extremely simple across a variety of supported databases using raw SQL, a fluent query builder, and the Eloquent ORM. Currently, Laravel provides first-party support for five databases: MariaDB 10.3+ (Version Policy) MySQL 5.7+ (Version Policy)

How does Laravel connect to external database?

In . env file you can set DB_CONNECTION with your database name and applicable databases are given in /config/database. php which are (SQLite, MySQL, pgSQL, SQLSRV) after that just type your username, password, and database name and you can use that database with port number.

How can check DB connection in Laravel?

Echo the Laravel database name in Blade/PHP The simplest way it to place the following script in a Blade or PHP file. This will output the name of the database or return 'none' if there is no connection. If you view it in the browser, it gives you the name of the connected database.


1 Answers

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.

like image 185
waza-ari Avatar answered Oct 05 '22 06:10

waza-ari