Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create log file of my web site in php? [closed]

Tags:

php

logging

I want to know how to create log file of my web site in php? Which help me to maintain data about Pages visited by each user & all actions they done in my website. So any buddy can help me?

Thanx,

like image 792
Vishal Avatar asked Dec 06 '11 13:12

Vishal


People also ask

How can I get PHP log?

Enabling the PHP Error LogLog messages can be generated manually by calling error_log() or automatically when notices, warnings, or errors come up during execution. By default, the error log in PHP is disabled. You can enable the error log in one of two ways: by editing php. ini or by using ini_set .

Where do PHP errors go?

By default, whenever an error or exception is thrown, PHP sends the error message directly to the user via STDOUT. In a command-line environment, this means that errors are rendered in the terminal. In a web environment, errors and exceptions get displayed directly in the browser.


1 Answers

$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);

Please see the manual page for file_put_contents().

like image 158
Developer Avatar answered Oct 14 '22 14:10

Developer