automatically creates file to log actions in PHP

//just TEXT log any action, and info about it, like a purchase, use for backup/internal storage
//I use this for all types of requests, when dealing with online payments

/* LOG */
file_put_contents('logs/'.date('Y.m').'.pay.log','['.$_SERVER['REMOTE_ADDR'].'] '.date('Y.m.d-H:i:s').': Order ID : '.$order_id.', Error : '.$error.', Sum'.$payed_sum.', Transaction : '.$transaction_id.PHP_EOL,FILE_APPEND);

//I recommend to keep the comma, for eventual csv reading
//automatically creates a single file per month, keeping the logs small
//keeps the IP and time stamp in a nice juman form

Simplest way to log actions in PHP

Processing your request, Please wait....

No Responses to “automatically creates file to log actions in PHP”

Comments (Your Comments)

Leave a Reply

You must be logged in to post a comment.