diff --git a/apps/bootstrap/protected/config/main.php b/apps/bootstrap/protected/config/main.php index 96e0986..20b5e7e 100644 --- a/apps/bootstrap/protected/config/main.php +++ b/apps/bootstrap/protected/config/main.php @@ -3,6 +3,7 @@ return array( 'id' => 'hello', 'basePath' => dirname(__DIR__), + 'preload' => array('log'), 'components' => array( 'cache' => array( 'class' => 'yii\caching\FileCache', @@ -14,6 +15,15 @@ return array( 'assetManager' => array( 'bundles' => require(__DIR__ . '/assets.php'), ), + 'log' => array( + 'class' => 'yii\logging\Router', + 'targets' => array( + 'file' => array( + 'class' => 'yii\logging\FileTarget', + 'levels' => array('error', 'warning'), + ), + ), + ), ), 'params' => array( 'adminEmail' => 'admin@example.com', diff --git a/framework/base/Application.php b/framework/base/Application.php index 5b92f76..ac7cc6a 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -8,7 +8,6 @@ namespace yii\base; use Yii; -use yii\helpers\FileHelper; /** * Application is the base class for all application classes. diff --git a/framework/logging/Logger.php b/framework/logging/Logger.php index 607c388..5c9a89d 100644 --- a/framework/logging/Logger.php +++ b/framework/logging/Logger.php @@ -6,7 +6,9 @@ */ namespace yii\logging; -use yii\base\InvalidConfigException; + +use \yii\base\Component; +use \yii\base\InvalidConfigException; /** * Logger records logged messages in memory. @@ -17,7 +19,7 @@ use yii\base\InvalidConfigException; * @author Qiang Xue <qiang.xue@gmail.com> * @since 2.0 */ -class Logger extends \yii\base\Component +class Logger extends Component { /** * Error message level. An error message is one that indicates the abnormal termination of the diff --git a/framework/logging/Router.php b/framework/logging/Router.php index 2f399fe..f544b72 100644 --- a/framework/logging/Router.php +++ b/framework/logging/Router.php @@ -28,16 +28,16 @@ use yii\base\Application; * 'preload' => array('log'), * 'components' => array( * 'log' => array( - * 'class' => '\yii\logging\Router', + * 'class' => 'yii\logging\Router', * 'targets' => array( * 'file' => array( - * 'class' => '\yii\logging\FileTarget', - * 'levels' => 'trace, info', - * 'categories' => 'yii\*', + * 'class' => 'yii\logging\FileTarget', + * 'levels' => array('trace', 'info'), + * 'categories' => array('yii\*'), * ), * 'email' => array( - * 'class' => '\yii\logging\EmailTarget', - * 'levels' => 'error, warning', + * 'class' => 'yii\logging\EmailTarget', + * 'levels' => array('error', 'warning'), * 'emails' => array('admin@example.com'), * ), * ), @@ -73,7 +73,6 @@ class Router extends Component public function init() { parent::init(); - foreach ($this->targets as $name => $target) { if (!$target instanceof Target) { $this->targets[$name] = Yii::createObject($target);