Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004178 [Quercus] minor always 08-12-10 11:37 04-04-13 19:06
Reporter domdorn View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 4.0.10
Summary 0004178: error_log not working correctly with files
Description It seems, that error_log is not working correctly when writing to files.
This is reported by a user, we need additional information on this.

File to look at:
modules/quercus/src/com/caucho/quercus/lib/ErrorModule.java

Current _guess_: The method only appends to files, so appending to a non existing file may fail on some Operating Systems.
We have to check if the error only happens when the destination file does not exist.

If you're experiencing this error, please comment on it and provide a testcase/testdata.



Additional Information
Attached Files  errorLogTest.php [^] (352 bytes) 08-13-10 08:25
 errorLogTestResultPage.png [^] (51,032 bytes) 08-13-10 08:28
 fileSystemPicture.png [^] (85,046 bytes) 08-13-10 08:35
 permissions.png [^] (60,262 bytes) 08-13-10 08:37

- Relationships

- Notes
(0004710)
kmoore4now
08-13-10 08:26

I've just uploaded our test php page that shows this condition.
 
(0004711)
kmoore4now
08-13-10 08:29

errorLogTestResultPage.png shows the result of executing the errorLogTest.php page. Note that the result indicates success.
 
(0004712)
kmoore4now
08-13-10 08:32

The WAR is deployed to Jboss 4.3.0.GA_CP02b102513 running on Mac OS X v10.5.8

The web.xml has this:

<servlet>
    <servlet-name>Quercus Servlet</servlet-name>
    <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>

  
 
    <init-param>
      <param-name>ini-file</param-name>
      <param-value>WEB-INF/php.ini</param-value>
    </init-param>
    
    <!--
      Location of the license to enable php to java compilation.
    -->
    <init-param>
      <param-name>license-directory</param-name>
      <param-value>WEB-INF/licenses</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>Quercus Servlet</servlet-name>
    <url-pattern>*.php</url-pattern>
  </servlet-mapping>

php.ini has this:

error_log="/Users/kmoore/error_log"
 
(0004713)
kmoore4now
08-13-10 08:35

fileSystemPicture.png shows that the error_log file exists in the specified directory.
 
(0004714)
kmoore4now
08-13-10 08:37

permissions.png shows that the error_log file has write permissions for everyone.
 
(0004715)
kmoore4now
08-13-10 08:48

This is shown in the Jboss console window after executing the test page:

[INFO] [talledLocalContainer] 13 Aug 2010 08:23:50,894 ERROR [STDERR] Aug 13, 2010 8:23:50 AM com.caucho.quercus.lib.ErrorModule error_log
[INFO] [talledLocalContainer] WARNING: test error log message
 
(0004716)
kmoore4now
08-13-10 09:09

Here is the content of error_log after executing the test:

line 1kmoore-osx-2:~ kmoore$ pwd
/Users/kmoore
kmoore-osx-2:~ kmoore$ cat error_log
line 1kmoore-osx-2:~ kmoore$

( I had added "line 1" before running the test )
 
(0004717)
domdorn
08-13-10 09:10

According to
http://en.php.net/manual/en/function.error-log.php [^]

 message_type

    Says where the error should go. The possible message types are as follows:

    error_log() log types 0 message is sent to PHP's system logger, using the Operating System's system logging mechanism or a file, depending on what the error_log configuration directive is set to. This is the default option.
    1 message is sent by email to the address in the destination parameter. This is the only message type where the fourth parameter, extra_headers is used.
    2 No longer an option.
    3 message is appended to the file destination. A newline is not automatically added to the end of the message string.

as you don't specify the destination, the default target is the system log.

so, if you want to write to your error-logfile, do it like this

error_log("My message", 3, "/Users/kmoore/error_log");

I would suggest you to create your own error_logging method to abstract this method, so you have your own function, e.g.

function log($logMessage){
return error_log($logMessage, 3, "/Users/kmoore/error_log");
}

http://de.php.net/manual/en/errorfunc.configuration.php#ini.error-log [^]
the documentation of the php.ini error_log specifies where script errors should be logged to, meaning if you have a syntax error in your page or an uncatched exception or something like that.

please try the error_log method with the additional arguments mentioned.


I'm updating the issue to state "no change required". If you think thats not correct, please feel free to post again and I'll open it up.

 
(0004718)
domdorn
08-14-10 03:57

Reopening as of user request.

This test demonstrates the bug:

<?
$logfile = '/tmp/testlog';
ini_set('error_log',$logfile);

$oldSize = filesize($logfile);
error_log("test");
$newSize = filesize($logfile);

assert( $newSize > $oldSize );

?>

which works in
php -v
PHP 5.3.2-1ubuntu4.2 with Suhosin-Patch (cli) (built: May 13 2010 20:03:45)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

but not in current quercus.

I assume this is the behavior you are expecting.
If not, please comment on this.
 
(0004730)
domdorn
08-18-10 12:14

fixed in svn r7412.

If you have access to resin's svn source, please try it out and give feedback.
 
(0006236)
nam
04-04-13 19:06

php/1811
php/1812

Fixed for 4.0.36.
 

- Issue History
Date Modified Username Field Change
08-12-10 11:37 domdorn New Issue
08-13-10 08:25 kmoore4now File Added: errorLogTest.php
08-13-10 08:26 kmoore4now Note Added: 0004710
08-13-10 08:28 kmoore4now File Added: errorLogTestResultPage.png
08-13-10 08:29 kmoore4now Note Added: 0004711
08-13-10 08:32 kmoore4now Note Added: 0004712
08-13-10 08:35 kmoore4now File Added: fileSystemPicture.png
08-13-10 08:35 kmoore4now Note Added: 0004713
08-13-10 08:37 kmoore4now File Added: permissions.png
08-13-10 08:37 kmoore4now Note Added: 0004714
08-13-10 08:48 kmoore4now Note Added: 0004715
08-13-10 09:09 kmoore4now Note Added: 0004716
08-13-10 09:10 domdorn Note Added: 0004717
08-13-10 09:10 domdorn Assigned To  => domdorn
08-13-10 09:10 domdorn Status new => resolved
08-13-10 09:10 domdorn Resolution open => no change required
08-13-10 09:11 kmoore4now Issue Monitored: kmoore4now
08-14-10 03:57 domdorn Status resolved => feedback
08-14-10 03:57 domdorn Resolution no change required => reopened
08-14-10 03:57 domdorn Note Added: 0004718
08-14-10 04:06 domdorn Note Added: 0004719
08-14-10 04:21 domdorn Note Deleted: 0004719
08-18-10 12:14 domdorn Note Added: 0004730
08-18-10 12:14 domdorn version 4.0.9 => 4.0.10
03-22-12 13:44 domdorn Assigned To domdorn =>
04-04-13 19:05 nam Status feedback => assigned
04-04-13 19:05 nam Assigned To  => nam
04-04-13 19:06 nam Status assigned => closed
04-04-13 19:06 nam Note Added: 0006236
04-04-13 19:06 nam Resolution reopened => fixed
04-04-13 19:06 nam Fixed in Version  => 4.0.36


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
58 total queries executed.
38 unique queries executed.
Powered by Mantis Bugtracker