Вопрос

I'm trying to get my errors in my error.log file to be on separate lines, but \n does not seem to be doing that. I feel like i'm missing something easy, but it's all on the same line so if i have a bunch of errors in there it will be almost impossible to find them.

<?php

$msg_one = "Error message 1.\n ";
$msg_two = "Error message 2.\n ";

$log_file = "C:\\inetpub\\wwwroot\\logging\\errors.log";

error_log($msg_one, 3, $log_file); 
error_log($msg_two, 3, $log_file);

?>

and the output in the log file looks like this:

Error message 1. Error message 2.
Это было полезно?

Решение

Use "\r\n" instead of "\n"

<?php

$msg_one = "Error message 1.\r\n ";
$msg_two = "Error message 2.\r\n ";

$log_file = "C:\\inetpub\\wwwroot\\logging\\errors.log";

error_log($msg_one, 3, $log_file); 
error_log($msg_two, 3, $log_file);

?>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top