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.