duanlei0282 2016-02-01 18:26
浏览 26
已采纳

Symfony:如何禁用访问方法的日志记录

I usually set the allowed methods via tag which returns 405 and logs error:

/**
 * @Method({'POST'});
 */

Is there a way how to set the logging level for only this action to info or not to log anything at all via some sort of configuration or another annotation?

Just side note: The URL in question is used in JavaScript for Ajax calls but has been fallowed by search engine and created several error level warnings that had to be manually proceed. This problem has been dealt with to some extend however the question above still stands.

  • 写回答

1条回答 默认 最新

  • dongtan1845 2016-02-01 18:26
    关注

    As it showed up. We had ExceptionListener already implemented so only what I had to do was change the handling of the exception there:

    class CustomExceptionListener extends ExceptionListener {
    
        protected function logException(\Exception $exception, $message, $original = true) {
            $flattenException = FlattenException::create($exception);
    
            if (null !== $this->logger) {
               //...
                    if ($exception instanceof NotFoundHttpException){
                        $this->logger->info($flattenException->getMessage() . "
    StackTrace: ");
                    } else if ($exception instanceof //...
                }
             // ...Rest of code omitted
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!