php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14615 PHP log does not contain proper CRLF's
Submitted: 2001-12-20 04:02 UTC Modified: 2013-08-06 09:37 UTC
From: timvandermolen at hotmail dot com Assigned: yohgaki (profile)
Status: Closed Package: PHP options/info functions
PHP Version: * OS: Windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: timvandermolen at hotmail dot com
New email:
PHP Version: OS:

 

 [2001-12-20 04:02 UTC] timvandermolen at hotmail dot com
In the PHP log, new lines are defined only with ASCII 10 (LF), but Windows only recognizes ASCII 13 + ASCII 10 (CRLF) as a new line.
This makes the PHP log look like a mess on Windows systems.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-20 04:10 UTC] mfischer@php.net
Your sentence doesn't compute: "[...] but Windows only recognizes ASCII 13 + ASCII 10 (CRLF) as a new line.". You mean, your editor is broken and does not support it.

No bug, bogusifying.
 [2001-12-20 04:23 UTC] hholzgra@php.net
well, different systems *have* different default
line ending styles, so we might want to write
whatever is considered 'native' on a certain
platform

but i'm not really sure what log we are talking
about here, as the default log mechanism (as i
know it on Linux/Apache) is to pass log messages
to the webserver for logging? 
 [2001-12-20 04:23 UTC] timvandermolen at hotmail dot com
There's nothing wrong with the editor. I have used Notepad to view the PHP log.

I have also viewed the PHP log with Visual C++ which *converts* (note the word convert) the LF to CRLF. Appearently, CRLF is the preferred format in Windows for new lines above LF.

Besides, CRLF is the new line format which practically every editor in Windows supports.

And besides everything: CRLF *is* the Windows newline, LF is not. So it would not make sense to use LF as a new line in Windows environments.
 [2001-12-20 04:28 UTC] timvandermolen at hotmail dot com
"but i'm not really sure what log we are talking about here"

I am talking about the PHP log file which can be defined with the directive "error_log = ..." in the PHP.INI file.
 [2001-12-20 04:36 UTC] mfischer@php.net
Reopen, leave Type: to Feature Request.
 [2001-12-20 04:52 UTC] hholzgra@php.net
now this is strange ...

the following snippet from php4/main/main.c
(around line 300) does the actual logging
and as it does *not* open the logfile in
binary mode it should automaticly convert
'\n' to whatever the local platform prefers???

  log_file = VCWD_FOPEN(PG(error_log), "a");
  if (log_file != NULL) {
    time(&error_time);
    strftime(error_time_str, 128
            , "%d-%b-%Y %H:%M:%S"
            , php_localtime_r(&error_time, &tmbuf)); 
    fprintf(log_file, "[%s] ", error_time_str);
    fprintf(log_file, "%s", log_message);
    fprintf(log_file, "\n");
    fclose(log_file);
    return;
  }

 [2010-12-29 11:58 UTC] jani@php.net
-Package: Feature/Change Request +Package: PHP options/info functions -PHP Version: 4.1.0 +PHP Version: *
 [2013-08-06 09:37 UTC] yohgaki@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: yohgaki
 [2013-08-06 09:37 UTC] yohgaki@php.net
At least 5.5 uses CR/LF under windows.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC