0

I've got a problem.

$log = error_log("/r/n $date, $username, $error", 3, "logs/login.txt");

I want a linebreak whenever a new error is send to the log.

but the log outputs:

2013-08-17 13:10:34, asdf, Logingegevens onjuist! /r/n2013-08-17 13:10:41, fffffff, Logingegevens onjuist! 

what am i doing wrong??

0

3 Answers 3

0

From the answer here:

...you should be able to change the error_log directive in your php.ini on Debian to point to a file. If this is undefined, it will go through syslog which doesn't support multiple lines.

This may happen if:

  • Apache can't write to into your error_log file
  • The error_log directive is empty

If it's the former, then you should be able to fix this by defining a file using the error_log directive in php.ini.

If it's the latter, then you can change the CHMOD permissions for that file and give Apache write access.

Documentation: error_log()

Sign up to request clarification or add additional context in comments.

Comments

0

If you're not using file logging then this won't work.

Otherwise, it's \r\n, not /r/n.

Comments

0

I don't script in php for long.. so first thanks for the replies.

The code I used now was:

$log_data = "$date, $ip, $username, $error \r\n";
$log = file_put_contents("logs/login.log", $log_data, FILE_APPEND | LOCK_EX);

with these variables:

$date = date("Y-m-d H:i:s");
$ip = GetHostByName("REMOTE_ADDR");

wich outputs: (ip blurred)

2013-08-19 13:28:28, x7.2xx.x5.x32, Vul alles in aub! 
2013-08-19 13:28:54, x7.2xx.x5.x32, Vul alles in aub! 
2013-08-19 13:28:58, x7.2xx.x5.x32, Vul alles in aub! 
2013-08-19 13:29:34, x7.2xx.x5.x32, admin, Login Succesvol! 
2013-08-19 13:35:02, x7.2xx.x5.x32, admin, Login Succesvol! 
2013-08-19 14:58:37, x7.2xx.x5.x32, admin Succesvol Uitgelogt!  
2013-08-19 14:58:44, x7.2xx.x5.x32, Paul, Logingegevens onjuist! 
2013-08-19 14:58:50, x7.2xx.x5.x32, admin, Login Succesvol! 

again: Thnx all

(sorry for bad English, I'm from Holland)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.