Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print log to terminal running artisan serve

Tags:

laravel

I am trying to debug my application and I had few log statements using Log facade. For now, I run the application using artisan serve and it will write the log message to the log file and to get a real time log message I run.

tail -f laravel.log

Is there any way I can directly print the log message to the same console/terminal that is running php artisan serve?

like image 733
geckob Avatar asked May 29 '16 13:05

geckob


People also ask

How do I run the artisan command on my server?

go to the root folder in which laravel is installed using cd command. In the root folder, run the command php artisan in terminal. It should work fine now.

How do I get Laravel logs?

By default, Laravel is configured to create a single log file for your application, and this file is stored in app/storage/logs/laravel. log .

How do I run artisan command in Laravel controller?

So we can do it by using Artisan facade. In Laravel Artisan facade that way we can easily run the all artisan command also with argument. So Artisan facade have two method one call() and another one is queue() through we can simply make process in call like seeder and also migration run etc.

How do I print an object in log?

Answer: Use console. log() or JSON. stringify() Method log() method, if you simply wants to know what's inside an object for debugging purpose. This method will print the object in browser console.

How to automatically start PHP artisan serve when sever starts?

Laravel server logs are stored in storage/logs folder ,which contains files for the server logs How to automatically start php artisan serve when sever (Apache) starts ? If you need to automatically ,A very simple way to do this would be to use use laravel scheduling Artisan Commands using cron

What is the Artisan command?

Artisan exists at the root of your application as the artisan script and provides a number of helpful commands that can assist you while you build your application. To view a list of all available Artisan commands, you may use the list command:

What artisan commands can I run in Tinker?

Tinker utilizes an "allow" list to determine which Artisan commands are allowed to be run within its shell. By default, you may run the clear-compiled, down, env, inspire, migrate, optimize, and up commands. If you would like to allow more commands you may add them to the commands array in your tinker.php configuration file:

Where Laravel PHP artisan serve command logs stored?

Where Laravel php artisan serve command logs stored ? Laravel server logs are stored in storage/logs folder ,which contains files for the server logs How to automatically start php artisan serve when sever (Apache) starts ?


2 Answers

You can do this using following. This works anywhere..

$output = new Symfony\Component\Console\Output\ConsoleOutput();
$output->writeln("<info>Error message</info>");

This will print the message in terminal / console that is running php artisan serve

like image 121
aquasmit Avatar answered Oct 14 '22 09:10

aquasmit


tail -f storage/logs/laravel.log & php artisan serve
like image 21
IllegalPigeon Avatar answered Oct 14 '22 09:10

IllegalPigeon