I am currently using the Silex Framework with Monolog as logging mechanism. I was able to successfully integrate the default Symfony WebProfiler in my project by using the following component - https://github.com/silexphp/Silex-WebProfiler (Silex-WebProfiler). It works, but unfortunately it cannot display the log messages from Monolog from its _profiler page. Does someone know how to solve that issue?
Here is my configuration if that's relevant at all:
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
));
}
I was wondering this, too, and I found these lines in MonologServiceProvider.
if ($bridge = class_exists('Symfony\Bridge\Monolog\Logger')) {
$app['monolog.handler.debug'] = function () use ($app) {
return new DebugHandler($app['monolog.level']);
};
}
The logging to the Web Profiler is enabled by the Symfony Monolog Bridge component. I added this to my composer.json
:
"symfony/monolog-bridge": "~2.3"
Now I see log entries in that panel of the web profiler. (It's probably a good idea to make sure the version of the monolog-bridge is in line with the versions of other Symfony components you've declared in your composer.json
.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.