LoggerAppenderFile: Warning: fopen(target/examples/file.log): failed to open
stream: Permission denied in /src/main/php/appenders/LoggerAppenderFile.php on
line 77
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: LOG4PHP-136
URL: https://issues.apache.org/jira/browse/LOG4PHP-136
Project: Log4php
Issue Type: Bug
Affects Versions: 2.0
Environment: Mac OSX, ubuntu 8.04, php 5.2.4
Reporter: David Pattison
LoggerAppenderFile emits a warning if it attempts to write to a log file that
it doesn't have permissions for. It would be nice if that never happened but
at least it should fail gracefully.
Steps to reproduce:
1. cd src/examples
2. create "appender_file_fail.php" (from appender_file.php):
<?php
// START SNIPPET: doxia
require_once dirname(__FILE__).'/../../main/php/Logger.php';
Logger::configure(dirname(__FILE__).'/../resources/appender_file.properties');
//make it fail by making the log file unwriteable
system("touch target/examples/file.log");
system("chmod 000 target/examples/file.log");
$logger = Logger::getRootLogger();
$logger->debug("Hello World!");//emits warning
Can we add something to LoggerAppenderFile::activeOptions() such as:
if (!is_writeable($fileName)) {
//report error???
$this->fp = false;
return;
}
To check if it the file writeable. Then Log4PHP can fail nicely.
-Dave
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira