Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

Creating a Log File in PHP

Here is the code that can save the system process to a .log file using php:

//Function: writeToLogFile($content,$flag) - To write every steps to the specified log file.
function writeToLogFile($content,$flag){
global $LOG_FILE;
$strRootPath = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$fp = fopen($strRootPath.$LOG_FILE,"a");
if ($flag)
$f_contents = date("Y-m-d H:i:s")."-".$content;
$f_contents = $content;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: