0

How to create seperate log file directory for php.

hello i need to store php log files on seperate directory.. how to create separate location to store php log files..

Php Add a comment
nicholas
asked Oct 20 2017

Answer

0

To write to a log file and make a new one each day, you could use date(""j.n.Y"") as part of the filename

//Something to write to txt log
$log = ""User: "".$_SERVER['REMOTE_ADDR'].' - '.date(""F j, Y, g:i a"").PHP_EOL.
""Attempt: "".($result[0]['success']=='1'?'Success':'Failed').PHP_EOL.
""User: "".$username.PHP_EOL.
""-------------------------"".PHP_EOL;
//Save string to log, use FILE_APPEND to append.
file_putcontents('./log'.date(""j.n.Y"").'.log', $log, FILE_APPEND);"

Add a comment
linuxhelp
asked Jan 14 2019
Post your Answer