logo

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ
No Result
View All Result
logo
No Result
View All Result
Trang chủ php application logging

Php application logging

by Admin _ April 28, 2021

class YeahMyController extends BaseController { public function getSomething() { Console::info("mymessage"); // Currently, I"m running the application using artisan (which runs PHP"s built-in development web hệ thống under the hood):

php artisan serveI would lượt thích to lớn log console messages to the STDOUT pipe for the artisan process.

Bạn đang xem: Php application logging


*

*

Aha!

This can be done with the following PHP function:

error_log("Some message here.");Found the answer here: Print something in PHPhường built-in web server


*

*

The question relates to lớn serving via artisan & so Jrop"s answer is ikhuyễn mãi giảm giá in that case. I.e, error_log logging khổng lồ the apache log.

However, if your serving via a standard web hệ thống then simply use the Laravel specific logging functions:

Log::info("This is some useful information.");Log::warning("Something could be going wrong.");Log::error("Something is really going wrong.");With current versions of laravel like this for info:

info("This is some useful information.");This logs khổng lồ Laravel"s log file located at /laravel/storage/logs/laravel-.log (laravel 5.0). Monitor the log - linux/osx: tail -f /laravel/storage/logs/laravel-.log


*

I haven"t tried this myself, but a quiông xã dig through the library suggests you can do this:

$output = new SymfonyComponentConsoleOutputConsoleOutput();$output->writeln("my message");I couldn"t find a shortcut for this, so you would probably want lớn create a facade lớn avoid duplication.

Xem thêm: Code Website Quản Lý Nhân Sự Php Full Code, Cài Đặt Và Tải Source Code Quản Lý Nhân


It"s very simple.

You can gọi it from anywhere in APP.

$out = new SymfonyComponentConsoleOutputConsoleOutput();$out->writeln("Hello from Terminal");
For better explain Dave sầu Morrissey"s answer I have made these steps for wrap with Console Output class in a laravel facade.

1) Create a Facade in your prefer thư mục (in my case appFacades):

class ConsoleOutput đầu ra extends Facade protected static function getFacadeAccessor() return "consoleOutput"; 2) Register a new Service Provider in appProviders as follow:

class ConsoleOutputServiceProvider extends ServiceProvider public function register() App::bind("consoleOutput", function() return new SymfonyComponentConsoleOutputConsoleOutput(); );

3) Add all this stuffs in configapp.php file, registering the provider and alias.

"providers" => < //other providers AppProvidersConsoleOutputServiceProvider::class >, "aliases" => < //other aliases "ConsoleOutput" => AppFacadesConsoleOutput::class, >,That"s it, now in any place of your Laravel application, just Gọi your method in this way:

Share Tweet Linkedin Pinterest
Previous Post

How to update php version in wordpress

Next Post

Type file php

CÙNG CHUYÊN MỤC

form register php

Form register php

09/04/2021
fantastic blog (cms) in php with source code

Fantastic blog (cms) in php with source code

28/04/2021
validate form php javascript

Validate form php javascript

28/04/2021
http diendanlequydon com viewtopic php style 6

Http diendanlequydon com viewtopic php style 6

28/04/2021
cách cài đặt php 7

Cách cài đặt php 7

24/01/2023
rövid videó

Rövid videó

23/01/2023
installing apache php mysql on ubuntu 18

Installing apache php mysql on ubuntu 18

20/01/2023
tính kế thừa trong oop php

Tính kế thừa trong oop php

20/01/2023

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ

News Post

  • The game download

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2023 darkedeneurope.com - Website WordPress vì mục đích cộng đồng

Liên Hệ - Giới Thiệu - Nội Quy - Bảo Mật

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Hỏi Đáp
    • Kiến Thức
    • Sức Khỏe
    • Tử Vi
    • Công Nghệ
  • Lưu trữ
  • Liên hệ

© 2023 darkedeneurope.com - Website WordPress vì mục đích cộng đồng.