如何在php中创建我的网站的日志文件?

Vis*_*ish 5 php logging

我想知道如何在php中创建我的网站的日志文件?这有助于我维护每个用户访问的页面数据以及他们在我的网站上完成的所有操作.那么任何哥们都可以帮助我吗?

感谢名单,

Dev*_*per 26

$file = 'people.log';
// The new person to add to the file
$person = "John Smith\n";
// Write the contents to the file, 
// using the FILE_APPEND flag to append the content to the end of the file
// and the LOCK_EX flag to prevent anyone else writing to the file at the same time
file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
Run Code Online (Sandbox Code Playgroud)

请参阅手册页file_put_contents().