Home  >  Article  >  Backend Development  >  Implementation method of writing logs in PHP, PHP log implementation_PHP tutorial

Implementation method of writing logs in PHP, PHP log implementation_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:15:081091browse

How to implement PHP log writing, PHP log implementation

The example in this article describes the implementation method of writing logs in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

Copy code The code is as follows:
function logError($content)
{
$logfile = '/logs/debuglog'.date('Ymd').'.txt';
if(!file_exists(dirname($logfile)))
{
@File_Util::mkdirr(dirname($logfile));
}
error_log(date("[Y-m-d H:i:s]")." -[".$_SERVER['REQUEST_URI']."] :".$content."n", 3,$logfile);
}


Note here that you need to give the directory permissions for logging:
Copy code The code is as follows:
chown -R www:www csevent/

If the www configured in your apache is not www, you need to change it to the corresponding one
You can use the ll command to check your permissions

I hope this article will be helpful to everyone’s PHP programming design.

How to write logs in php

Logging in PHP is very frustrating. . .
Insert it into the database, there is no other good way. .
For large amounts of data, you can first record the data into a file according to the format, and then load it into the database.

PHP assignment: Design and implementation of logging system

Something is wrong but the method is like this. We wrote a log once and it is still helpful in some aspects. Take a look for yourself

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/906666.htmlTechArticle Implementation method of PHP logging, php log implementation This article describes the implementation method of PHP logging. Share it with everyone for your reference. The specific implementation method is as follows: Copy the code The code is as follows...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn