Log-log solution in the php Program

Source: Internet
Author: User
I am still a beginner php developer. I only use exit () and die () for errors. Now I suddenly think that the user will tell me the program error information if he doesn't understand the program, of course not, so I want to add the log function to my website to record user behavior by the way. I plan to use the database to record... I am still a beginner php developer. I only use exit () and die () for errors. Now I suddenly think that the user will tell me the program error information if he doesn't understand the program, of course not, so I want to add the log function to my website to record user behavior by the way.
We plan to use a database to record
Shard id, level, log, time
Is this enough?

Reply content:

I am still a beginner php developer. I only use exit () and die () for errors. Now I suddenly think that the user will tell me the program error information if he doesn't understand the program, of course not, so I want to add the log function to my website to record user behavior by the way.
We plan to use a database to record
Shard id, level, log, time
Is this enough?

Of course, you can implement a log system by yourself and store it in any media you want (such as File, Mysql, MongoDB, and Redis). This is also the case for many people. Of course, if you are too reluctant to do such a system for the time being, php also has native functions that allow you to record logs in the specified file and add them to any row in the program.

Error_log ('any string you want to record ', 3,'/Your/log file/path ');

The upstairs is good, and the error log can print arrays perfectly.

Try KLogger

You can use the seaslog plug-in to specify the file output,

Come on, I'll give you a simple one:

Https://github.com/thenbsp/lib/blob/master/Logger.php

Example:

$logger = new Logger();$logger->debug('debug message');$logger->debug('error message');$logger->debug('warning message');

It is recommended that you know about the log interface standard of the SRS 3 php, and there are many implementations of this interface.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.