簡體   English   中英

如何在Silex-WebProfiler中集成Monolog?

[英]How to integrate Monolog in the Silex-WebProfiler?

我目前正在使用帶有Monolog的Silex Framework作為日志記錄機制。 通過使用以下組件 - https://github.com/silexphp/Silex-WebProfiler(Silex-WebProfiler ),我能夠成功地將默認的Symfony WebProfiler集成到我的項目中。 它可以工作,但不幸的是它無法從其_profiler頁面顯示來自Monolog的日志消息。 有人知道如何解決這個問題嗎?

這是我的配置,如果這是相關的:

use Silex\Provider;
...
//Monolog
$app->register(new Provider\MonologServiceProvider(), array(
    'monolog.logfile' => __DIR__ . '/../log/development.log',
    'monolog.name'    => 'MyAppName'
));
...
// Web Profiler
if ($app['debug']) {
    $app->register(new Provider\WebProfilerServiceProvider(), array(
        'profiler.cache_dir' => __DIR__.'/../cache/profiler/',
        'profiler.mount_prefix' => '/_profiler', // this is the default
    ));    
}

我也想知道這一點,我在MonologServiceProvider中找到了這些行。

if ($bridge = class_exists('Symfony\Bridge\Monolog\Logger')) {
    $app['monolog.handler.debug'] = function () use ($app) {
        return new DebugHandler($app['monolog.level']);
    };
}

Symfony Monolog Bridge組件啟用了對Web Profiler的日志記錄。 我把它添加到我的composer.json

"symfony/monolog-bridge": "~2.3"

現在,我在Web Profiler的該面板中看到了日志條目。 (確保monolog-bridge的版本與您在composer.json聲明的其他Symfony組件的版本一致,這可能是一個好主意。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM