在用户结霜中启用 logwriter
Enabling logwriter in Userfrosting
我正在尝试使用内置的 Slim logwriter,但目前还没有成功。
这就是我正在尝试的方法,但出现错误。
改为config_userfrosting.php:
/*Create a log writer */
$logWriter = new \UserFrosting\LogWriter(fopen('C:\xampp\htdocs\userfrosting\log\dev_logfile.log', 'a'));
$app->configureMode('dev', function () use ($app, $public_path, $uri_public_root) {
$app->config([
'log.enable' => true,
'log.writer' => $logWriter,
'debug' => false,
从 index.php 调用日志编写器:
$app->log->debug("This is a test from the logger...");
收到错误:
PHP Notice: Undefined variable: logWriter in \userfrosting\config-userfrosting.php on line 33
为了在闭包 (configureMode
) 中访问变量,您需要将其与 use(...)
个参数列表一起传递:
$app->configureMode('dev', function () use ($app, $public_path, $uri_public_root, $logWriter) {
$app->config([
'log.enable' => true,
'log.writer' => $logWriter,
'debug' => false,
...
});
我正在尝试使用内置的 Slim logwriter,但目前还没有成功。
这就是我正在尝试的方法,但出现错误。
改为config_userfrosting.php:
/*Create a log writer */ $logWriter = new \UserFrosting\LogWriter(fopen('C:\xampp\htdocs\userfrosting\log\dev_logfile.log', 'a')); $app->configureMode('dev', function () use ($app, $public_path, $uri_public_root) { $app->config([ 'log.enable' => true, 'log.writer' => $logWriter, 'debug' => false,
从 index.php 调用日志编写器:
$app->log->debug("This is a test from the logger...");
收到错误:
PHP Notice: Undefined variable: logWriter in \userfrosting\config-userfrosting.php on line 33
为了在闭包 (configureMode
) 中访问变量,您需要将其与 use(...)
个参数列表一起传递:
$app->configureMode('dev', function () use ($app, $public_path, $uri_public_root, $logWriter) {
$app->config([
'log.enable' => true,
'log.writer' => $logWriter,
'debug' => false,
...
});