私はZF 3アプリケーションを持っています。明示的にログするメッセージ(例:$log->debug()
)例外はありません。エラーが表示されるように見えるのは、これがデフォルトのPHP設定でstderrに行くからです。Zend-Logのエラーハンドラと例外マネージャを正しく設定していますか?
'service_manager' => [
'factories' => [
. . . .
'log' => \Zend\Log\LoggerServiceFactory::class,
],
],
'log' => [
'writers' => [
[
'name' => 'stream',
'options' => [ 'stream' => 'php://stderr' ]
],
],
'errorHandler' => true,
'exceptionhandler' => true,
],
The lines in the source that lead me to believe this is the correct config:ここmodules.config.phpから関連する行です。すべて(
public function errorAction()
{
$msg = $this->params()->fromQuery('msg', 'Default Error message');
trigger_error('Index Error Action' . $msg, E_USER_ERROR);
$model = new JsonErrorModel(['msg' => $msg]);
return $model;
}
public function exceptionAction()
{
$msg = $this->params()->fromQuery('msg', 'Default Error message');
throw new \RuntimeException('Index Exception Action' . $msg);
$model = new JsonErrorModel(['msg' => $msg]);
return $model;
}
これを修正し、致命的なエラーログを追加しました。私はまだログにthmeが表示されません。サンプルのエンドポイントが機能していないという質問を編集しました。例外は未処理です。 –
私は私の答えを編集..あなたはちょうどロガーを初期化していない。設定ファイルでservice/modelを登録しますが、Zendは最初にこのサービスを呼び出した後にクラスを作成します。おかげさまで – SzymonM
それはそれをした! –