我正在嘗試使用PhalconPHP來進行調試。Phalcon記錄器/文件適配器不能正常工作
但不管我用什麼代碼,它加載瀏覽器的時候給了我這個錯誤:
Can't open log file at 'app/logs/test.log'
#0 /home/myuser/public_html/demo1/app/controllers/UsersController.php(6): Phalcon\Logger\Adapter\File->__construct('app/logs/test.l...')
#1 [internal function]: unknown()
#2 [internal function]: Phalcon\Loader->autoLoad('UsersController')
#3 [internal function]: spl_autoload_call('UsersController')
#4 [internal function]: Phalcon\Dispatcher->_dispatch()
#5 [internal function]: Phalcon\Dispatcher->dispatch()
#6 /home/myuser/public_html/demo1/public/index.php(42): Phalcon\Mvc\Application->handle()
#7 {main}
<?php
use Phalcon\Logger\Adapter\File as FileAdapter;
// Create the file logger in 'w' mode
$logger = new FileAdapter("app/logs/test.log", array(
'mode' => 'w'
));
供參考:所有的記錄代碼在一個爾康控制器測試。
$logger = new \Phalcon\Logger\Adapter\File("app/logs/test.log");
$logger->log("This is a message");
$logger->log(\Phalcon\Logger::ERROR, "This is an error");
$logger->error("This is another error");
$logger->close();
use Phalcon\Logger;
use Phalcon\Logger\Adapter\File as FileAdapter;
$logger = new FileAdapter("app/logs/test.log");
$logger->log(
"This is a message"
);