NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
* 配置 Log组件是基于Monolog组件封装实现的,在应用层配置文件中 ~~~ 'components' => [ 'log' => [ 'class' => 'Swoolefy\Tool\Log', 'channel’=> 'Application', 'logFilePath' => rtrim(LOG_PATH,'/').'/runtime.log'; ], ] ~~~ 可选的全局配置项: channel:是指log保存的主题 logFilePath:log存储日志文件路径 output:日志输出格式,默认格式`"[%datetime%] %channel% > %level_name% : %message% \n"`,可以参考Monolog组件 在实际使用中也可以覆盖默认的全局配置,例如: ~~~ switch($errorType) { case 'error': Application::getApp()->log->setChannel('Application')->setLogFilePath($logFilePath)->addError($errorMsg); break; case 'warning': Application::getApp()->log->setChannel('Application')->setLogFilePath($logFilePath)->addWarning($errorMsg); break; case 'notice': Application::getApp()->log->setChannel('Application')->setLogFilePath($logFilePath)->addNotice($errorMsg); break; case 'info': Application::getApp()->log->setChannel('Application')->setLogFilePath($logFilePath)->addInfo($errorMsg); break; } ~~~ 函数setChannel()可以覆盖原来组件定义的信道 函数setLogFilePath()可以覆盖原来组件定义的文件路径