Giter Site home page Giter Site logo

monolog-bundle's Introduction

MonologBundle

The MonologBundle provides integration of the Monolog library into the Symfony framework.

More information in the official documentation.

License

This bundle is released under the MIT license

monolog-bundle's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

monolog-bundle's Issues

How can I add handler programmatically?

Hi,

normally you add monolog handlers in the config*.yml files. In my current bundle I want to push my own handler on the top of the stack. I used the PrependExtensionInterface to configure the handlers. But $container->prependExtensionConfig('monolog', $myHandler); always create two handlers keys. One contains my definitions, the other the handler definitions from the `config*.yml' file.

I read the docs and found:

If you want to change the config of MonologBundle in another config file you need to redefine the whole stack. It cannot be merged because the order matters and a merge does not allow to control the order.

My bundles monolog handler extends the TestHandler. I want to collect all messages refers to the bundles webservice communication. The bundle uses that messages to show a user friendly jquery tracelog if something is broken.

Is it possible to add my handler without saying: " _If you want to use my bundle, add the following monolog handler definition to your config_.yml ...* "?

Question: how to mute channels

In order to "mute" log messages from the "event" channel, I have this configuration in my bundle:

monolog:
    handlers:
        main:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
            channels: [""!event"]
        mute:
            type: "null"
            channels: ["event"]

This is effective, but are there other ways to mute channels? What happens by default with messages that are excluded by any of the handlers? I noticed them popping up in the output of the PHPStorm PHPUnit test runner, but I couldn't find any piece of code in the bundle or the library that could be the cause of this.

Error if spool config value not set

I just upgraded to Symfony 2.4 and Monolog 2.5.0. If you do not use spooling, you receive the following error:

The service "monolog.handler.swift" has a dependency on a non-existent service "swiftmailer.transport.real".

This occurs since the alias never gets created if you do not set the 'spool' value under the Swiftmailer configuration.

Lazy loaded Swift_Message can cause unserialize errors when using file spool

When storing message in file it will be serialized with class name like Swift_Message_000000003b027a18000000005cb90b1f. After container rebuild this name will change. So if cache was cleared after message stored but before swiftmailer:spool:send command executed there will be error Catchable Fatal Error: Argument 1 passed to Swift_Transport_MailTransport::send() must implement interface Swift_Mime_Message, instance of __PHP_Incomplete_Class given.

This is a rare but troublesome case.

Lazyloaded Swift_Message fails to initialize when using memory queue.

Since #109 the Swift_Message used for email logging is lazy-loaded. This seems to interact badly with the memory queue strategy, because it clones messages.

It seems only the initial message is properly (lazily) initialized, but the clone is not, so, this might be an error in the lazy load library as well, but I figure I mention it here since this is where I first ran into this effect.

The specific error you'll get is: Fatal error: Uncaught exception 'Swift_TransportException' with message 'Cannot send message without a sender address'

Additional channels in XML config not possible

Hello,

As of Monolog Bundle 2.4 it should be possible to define additional channels in the monolog config:

http://symfony.com/doc/current/cookbook/logging/channels_handlers.html

However, when I define them in XML as per the example on the above page the XSD does not validate:

[ERROR 1871] Element '{http://symfony.com/schema/dic/monolog}channel': This element is not expected. Expected is ( {http://symfony.com/schema/dic/monolog}handler ).

The monolog-1.0.xsd also does not mention the 'channel' element to be allowed in the 'config' element besides the 'handler' element.

Is this a bug?

channel filtering

Hi,

I usually use channel filtering in my logging and I just started a new project and noticed that the channels filtering is not working.

Symfony version: ~2.4
Monolog version: 1.10.x-dev (the default for symfony 2.4)

in my config_dev.yml I have this:

monolog:
    handlers:
        main:
            type:     group
            channels: ["app", "doctrine", "!event"]
            members:  [streamed, console]
        streamed:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
        console:
            type:   console
            verbosity_levels:
                VERBOSITY_NORMAL: INFO
            level:      debug

I'm getting "event.DEBUG" and "request.INFO" in my logs, although I've set it to log only app and doctrine stuff and explicitly excluded event.
Did something changed? Am I doing something wrong? Or is this a bug?

Tkx

Parameterized channel

At the moment the channel parameter is taken as-is:

            $loggerId = sprintf('monolog.logger.%s', $tag['channel']);
            $this->createLogger($tag['channel'], $loggerId, $container);

whereas I find it useful if it was possible to make it a parameter so that you only needed to specify/change it in one place.

Thoughts?

Unexistent branch for 2.4 and 2.5

There're no trackable branches for MonologBundle 2.4 and 2.5, even though there are already releases for both branches.

If we decide to keep track of 2.5.X series, we are forced to track dev-master, which will likely result into future changes easily since this is being used as latest development efforts.

MonologBundle processor per handler

Problem description:
The configuration option for processors per handler is not available.

Docs: http://symfony.com/doc/current/cookbook/logging/monolog.html#adding-a-session-request-token

If you use several handlers, you can also register the processor at the handler level instead of globally.

Example: https://github.com/symfony/MonologBundle/blob/master/DependencyInjection/Configuration.php#L562

Error:

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized options "processors" under "monolog.handlers.main"

Config:

monolog:
    handlers:
        main:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
            processors: [@monolog.processor.log]

Notice that no actual configuration option for "processors" can be found in the DI configuration.

Note: this is a copy of symfony/symfony#10704

Monolog Upgrade?

Currently this bundle is at 1.6 of monolog while the monolog repo is currently at 1.8. 1.8 provides newer GELF support as well as a flurry of new handlers. Is there a change that this bundle will get upgraded soon?

Formatter is missing from XSD

The formatter seems to have been accidently removed from the XSD, causing the config file to fail validation when the service container is built.

Wrong transport used in AddSwiftMailerTransportPass

If we are using several mailers configurations with swiftmailer:

# app/config/config.yml
swiftmailer:
    default_mailer: default
    mailers:
        default:
            ...
        errors:
            ...

and specifying a non-default mailer in monolog:

# app/config/config_prod.yml
monolog:
    handlers:
        mail:
            type:         fingers_crossed
            action_level: critical
            handler:      buffered
        buffered:
            type:    buffer
            handler: swift
        swift:
            type:       swift_mailer
            # This is the specified mailer service :
            mailer:     swiftmailer.mailer.errors 
            from_email: [email protected]
            to_email:   [email protected]
            subject:    An Error Occurred!
            level:      debug

When doing this, the definition of the monolog handler is correct.
But the problem is in the class AddSwiftMailerTransportPass of MonologBundle (current version), this CompilerPass adds the setTransport method to the handler definition with the default transport. (Here and here)

When using only one mailer, it's working.

When using a non-default mailer in monolog, the mails are not sent because the transport (aka the spool) used is the one of the default mailer.

I made it work but it's not perfect :

<?php

namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Reference;

class AddSwiftMailerTransportPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        $handlers = $container->getParameter('monolog.swift_mailer.handlers');

        foreach ($handlers as $id) {
            $definition = $container->getDefinition($id);

            // This is my current solution
            // I'm retrieving the argument nยฐ0 of this monolog handler definition 
            // (arg nยฐ0 is a reference to the swiftmailer mailer), so when
            // calling _toString(), I can retrieve the id of the mailer and use
            // it for building the id of the correct transport.
            $mailerId = $definition->getArgument(0)->__toString();

            if (
                $container->hasAlias($mailerId . '.transport.real') ||
                $container->hasDefinition($mailerId . '.transport.real')
            ) {
                $definition->addMethodCall(
                     'setTransport',
                     array(new Reference($mailerId . '.transport.real'))
                 );
            } elseif (
                $container->hasAlias($mailerId . '.transport') ||
                $container->hasDefinition($mailerId . '.transport')
            ) {
                $definition->addMethodCall(
                     'setTransport',
                     array(new Reference($mailerId . '.transport'))
                 );
            }
        }
    }
}

What do you think of this solution ?

Does anybody has a better way to fix this bug ?

Make Monolog format configurable in Symfony

I should be able to config the format of monolog simply, to be able to output for example class and method. This works, in that it does make the format as described int he arguments:

services:
    my_log_formatter:
        class: Monolog\Formatter\LineFormatter
        arguments: ["[%%datetime%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n"]

monolog:
    handlers:
        file:
            type: stream
            level: debug
            formatter: my_log_formatter

...but trying to add %O (class) or %M (method) to the arguments, which are supported by Monolog, does not configure the logger format.

ContextErrorException: Warning: constant(): Couldn't find constant Monolog\Logger::DEBUG

Hi,

I've added Monolog Bundle in my composer like so:

  "symfony/monolog-bundle": "~2.4"

But I get these errors:

ContextErrorException: Warning: constant(): Couldn't find constant Monolog\Logger::DEBUG in [path]/symfony/monolog-bundle/Symfony/Bundle/MonologBundle/DependencyInjection/MonologExtension.php line 119

Fatal error: Class 'Monolog\Logger' not found in [path]/Symfony/Bundle/MonologBundle/DependencyInjection/Compiler/DebugHandlerPass.php on line 42

And I'm also using symfony 2.4.

Sending HTML emails with SwiftMailerHandler handler

It would be nice if you could configure the SwiftMailerHandler to send emails as HTML. Currently you can send emails only with text/plain.

You could add optional content_type parameter to the configuration, to specify the content type:

    swift:
        type:         swift_mailer
        from_email:   [email protected]
        to_email:     [email protected]
        subject:      An Error Occurred!
        content_type: text/html
        level:        debug

Wrong branch for tag 2.3.1

@Seldaek The 2.3.1 tag have been made on the master branch instead of the 2.3 branch.

Now when installing symfony 2.3.1 monolog-bundle require monolog-brige >=2.4-dev

  Problem 1
- Installation request for symfony/monolog-bundle 2.3.1 -> satisfiable by symfony/monolog-bundle[v2.3.1].
- symfony/monolog-bundle v2.3.1 requires symfony/monolog-bridge >=2.4-dev,<3.0 -> no matching package found.

Cannot use the NullHandler with XML configuration

Hi,

I'm working on a Symfony 2 application, and I'd like to temporary disable logging.
I found that adding the NullHandler on top of the configured handlers shall do the job.
Here's my monolog XML configuration:

<monolog:config>
    <monolog:handler name="null_handler" type="null" />
    <monolog:handler name="file_handler" type="stream" level="info" path="%kernel.logs_dir%/%kernel.environment%.log" />
</monolog:config>

However, when I access a web page, this error occured:

InvalidArgumentException in MonologExtension.php line 611:
Invalid handler type "" given for handler "null_handler"

It seems the null type in the XML parameter is treated as a blank string, and I guess there may be an issue in the Configuration class of the bundle.
What is your opinion?

Thanks for your help,
BR

Creating multiple gelf handlers sends all messages to only one

I've creating the following configuration:

monolog:
    handlers:
        main:
            type:           fingers_crossed
            action_level:   critical
            handler:        nested
        nested:
            type:           stream
            path:           "%kernel.logs_dir%/%kernel.environment%.log"
            level:          debug
        info:
            type:           stream
            path:           "%kernel.logs_dir%/%kernel.environment%.log"
            level:          info
        graylog2:
            type:           gelf
            level:          info
            publisher:
                hostname:   %logging_host%
                port:       12201
        graylog2_ita:
            type:           gelf
            level:          info
            publisher:
                hostname:   151.x.x.x
                port:       12201
        console:
            type:           console

The problem is that both messages for graylog2 and graylog2_ita are sent to the last one (duplicated).

I've tried to use also a key "name" inside the handlers and the groupHandler but still they're sent to only one of the servers.

New Release

Hi,

would it be possible to create a new release (2.6.2 ?) since there are a lot of new supported handlers since 2.6.1 was created on July 21st ? I'm particularly interested in the Slack one.
Thanks !

failed to open stream: No such file or directory

Hi,

since Monolog-Bundle switched to PSR-4 we get this error in our symfony 2.5 app:

*32004 FastCGI sent in stderr: "PHP message: PHP Warning:  require(/src/vendor/symfony/monolog-bundle/Symfony/Bundle/MonologBundle/MonologBundle.php): failed to open stream: No such file or directory in /src/app/bootstrap.php.cache on line 2683

vendors are installed with php composer.phar install --no-dev --optimize-autoloader

composer.json entry:
"symfony/monolog-bundle": "~2.4"

Not activate channel on DefinitionDecorator instance

Hi.

The channel for logger not activate, if i use DefinitionDecorator instance for create service.

As example:

<service id="api.subscriber.logger_abstract" class="%api.subscriber.logger.class%" abstract="true" public="false">
    <argument type="service" id="logger" />
</service>

And after i create a DefinitionDecorator and add monolog.logger tag for this service and inject to container.

$subscriberDefinition = new DefinitionDecorator('api.subscriber.logger_abstract');
$subscriberDefinition->addTag('monolog.logger', [
    'channel' => $this->getLoggerChannelForHandler($handlerKey)
]);

$container->setDefinition($subscriberId, $subscriberDefinition);

The problem in DefinitionDecorator, because here not have a arguments. Argument and another definition options will be processed on ResolveDefinitionTemplatesPass (Optimization layer on compiler pass).

Maybe add LoggerChannelPass to optimization layer on CompilerPass?:

$container->addCompilerPass($channelPass = new LoggerChannelPass(), PassConfig::TYPE_OPTIMIZE);
$container->addCompilerPass(new DebugHandlerPass($channelPass), PassConfig::TYPE_OPTIMIZE);

Thank.

Be able to change the class of Raven_Client in Raven Handler

Right now, the client is very hard to customize because of the sha1 on the raven dns,
So I created this code in my application:

<?php

namespace SensioLabs\Bundle\InsightAnalysisBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;

/**
 * This code may be deprecated one day by
 * https://github.com/symfony/MonologBundle/issues/85
 */
class RavenPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('monolog.handler.raven')) {
            return;
        }

        $definition = $container->getDefinition('monolog.handler.raven');
        $container->getDefinition($definition->getArgument(0))->setClass('SensioLabs\Shim\Raven\Client');
    }
}

Can I submit a PR to "parameterized" a monolog.raven.client.class ?

Thanks

missing LICENSE file

Various copyright notices mention a file LICENSE that supposedly is "distributed with this source code". However, I cannot find such file.

Please add this file with appropriate license terms.

It is impossible to override core handlers

@Seldaek

Cause Symfony 2.3 could catch PHP Fatal errors I'd like to send email notifications when PHP Fatal occurs.

Basically it works well with Monolog bundle and SwiftMailer handler. And currently in my app these emails are sent properly. But I'd like to customize email content to include here a bit more useful information.

What I'm wondering, is here any ability to override core handler class? For example it is impossible to override monolog.handler.swift_mailer.class (it is need to create separate compiler pass to completely override service definition).

From how I understand it is because handler definitions are built in container extension (just after bundle configuration is processed). From my point it will be more correct to build it in compiler pass.

I could miss something cause I'm looking in MonologBundle source code for first time.

Thanks in advance!

Allow to add processors via configuration

Monolog and the Monolog-bridge come with some pre-defined processors to use. It would be nice, if one could enable them easily via configuration, like

monolog:
  handlers: ~ # define your handlers here (omitted)
  processors:
    foo:
      type: memory_peak_usage
      real_usage: true
      use_formatting: false
      channels: [bar, baz]
    bar:
      type: psr_log_message
      handlers: [mainfile]

Add Psr\Log\LoggerInterface to classes to compile

Hello, since Monolog is based on PSR-3 most classes the depend on a logger can typehint against Psr\Log\LoggerInterface.
I was wondering if it could be added to the classes to compile (here), I haven't find any discussion about it so I'm not sure what are the arguments against it.

how to make symfony2 writes log in prod mode?

I would like to make symfony writes in the file app/logs in prod mode.
To do so, I changed the config of monolog in config_prod.yml

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      nested
        nested:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug

But, not prod.log file is generated!

Since the log is produced in dev mode, I copied than the monolog config which is available in config_dev.yml to the config_prod.yml. This config is follows:

monolog:
    handlers:
        main:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        firephp:
            type:  firephp
            level: info
        chromephp:
            type:  chromephp
            level: info

But, still no prod.log is written in prod mode.

Is there any idea?

For your information , I am using symfony 2.3.11.

Can i have custom Levels in monolog

Currently i am using custom entity manager to write my logs
But i only want to log those things which i manually want to log.

logger1:
type: stream
path: /var/log/file1.log
level: MY_CUSTOM_LEVEL

logger1:
type: stream
path: /var/log/file2.log
level: MY_CUSTOM_LEVEL2

$logger.log("This is for level 1","MY_CUSTOM_LEVEL")

Add extra param for Gelf

Hi,

I use monologBundle to log into GrayLog2. So I use GelfHandler and GelfMessageFormatter given by monolog. It work very well but I encoutered a limitation.

In GrayLog, it's possible to send extra additional fields

In GelfMessageFormatter.php

foreach ($record['extra'] as $key => $val) {
    $message->setAdditional($this->extraPrefix . $key, is_scalar($val) ? $val : $this->toJson($val));
}

But in Monolog/Logger addRecord function the extra field is set to array().

$record = array(
    'message' => (string) $message,
    'context' => $context,
    'level' => $level,
    'level_name' => static::getLevelName($level),
    'channel' => $this->name,
    'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone)->setTimezone(static::$timezone),
    'extra' => array(),
);

So I can't send extra field to GrayLog.

Do you have a solution or can you fix this ?

Add support for new handlers

Missing handlers:

  • mongodb
  • couchdb / doctrinecouchdb
  • elasticsearch / elastica
  • dynamodb
  • syslogd
  • loggly
  • browserconsole (might need to be made the default in the standard edition if it works well)
  • filter
  • flowdock
  • rollbar
  • whatfailuregroup
  • mandrill
  • slack
  • fleephook
  • sampling

dev-master does not fetch "psr\log" as Monolog's dependency

Using monolog/monolog (25a97a) (dev-master) for the development purposes with symfony/monolog-bundle @dev does not fetch psr/log dependency and results in rising exception right after composer update:

PHP Fatal error:  Interface 'Psr\Log\LoggerInterface' not found in 
/path/vendor/monolog/monolog/src/Monolog/Logger.php on line 28

Do you have any idea why does it not work properly? Fetching monolog/monolog and calling composer update works and psr is available under vendor folder.

Ability To Specify System Name

I think it would be helpful if the user was allowed to specify the system name (or source) to be used for logging. I use GELF, but would like to use a parameter in my config for the system name not the computers hostname.

MonologBundle error on install

I was doing: php composer.phar update and got

  • Updating monolog/monolog (dev-master 52b454f => 1.2.1)
    Checking out 1.2.1

  • Updating symfony/monolog-bundle (dev-master v2.1.5 => 2.1.x-dev v2.2.0-BETA1)
    Checking out v2.2.0-BETA1
    ...
    PHP Fatal error: Class 'Symfony\Bundle\MonologBundle\MonologBundle' not found in /srv/www/htdocs/icms/app/AppKernel.php on line 10
    PHP Stack trace:
    ...
    Fatal error: Class 'Symfony\Bundle\MonologBundle\MonologBundle' not found in /srv/www/htdocs/icms/app/AppKernel.php on line 10
    ...
    Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception

    [RuntimeException]
    An error occurred when executing the "'cache:clear --no-warmup'" command.

Now every time I run php app/console cache:clear now I get the error as well.

cannot be installed with Symfony 2.2.0-RC1

"symfony/symfony": "v2.2.0-RC1",
"symfony/monolog-bundle": "v2.1.7"

or

"symfony/symfony": "v2.2.0-RC1",
"symfony/monolog-bundle": "v2.2.0-BETA1"

result in

PHP Fatal error: Class Symfony\Bridge\Monolog\Logger contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods (Psr\Log\LoggerInterface::emergency, Psr\Log\LoggerInterface::critical, Psr\Log\LoggerInterface::error, ...) in vendor/symfony/symfony/src/Symfony/Bridge/Monolog/Logger.php on line 90


"symfony/symfony": "v2.2.0-RC1",
"symfony/monolog-bundle": "v2.2.0-BETA2"

results in

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for symfony/monolog-bundle v2.2.0-BETA2 -> satisfiable by symfony/monolog-bundle v2.2.0-BETA2.
    - symfony/monolog-bundle v2.2.0-BETA2 requires symfony/config >=2.2,<3.0 -> satisfiable by symfony/config 2.2.x-dev, symfony/config 2.3.x-dev.
    - don't install symfony/config 2.2.x-dev|don't install symfony/symfony v2.2.0-RC1
    - don't install symfony/config 2.3.x-dev|don't install symfony/symfony v2.2.0-RC1
    - Installation request for symfony/symfony v2.2.0-RC1 -> satisfiable by symfony/symfony v2.2.0-RC1.

[Question] MonologBundle + long running process

I have a long running console command for testing:

protected function execute(InputInterface $input, OutputInterface $output)
{    

    $container = $this->getContainer();
    $logger = $container->get('logger');

    $lim = 5000;
    $count = 0;
    while (true){
        $count++;
        $logger->debug("line one");
        $logger->debug("line two");
        $logger->debug("line three");
        #var_export($logger);
        if ($count >= $lim){
            break;
        }
    }
}

and my prod config looks like this:

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      nested
            buffer_size:  30
        nested:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug

The elements in the buffer do not exceed the limit, but the overall memory usage of the process is still increasing with every iteration.
If I let the process run for a few minutes it gets over 1gb and i have no idea where the memory increase comes from.

I also did some profiling with xdebug but it doesn't help too much:

function                                                                                        #calls  time     memory  time     memory
----------------------------------------------------------------------------------------------------------------------------------------
Monolog\Logger->addRecord                                                                        15000  19.2248 -2024304  6.6741 12480632
Composer\Autoload\includeFile                                                                      245  0.6489  7826512  0.2820  5104360
sprintf                                                                                          15002  1.0057  3840680  1.0057  3840680
Monolog\Logger->debug                                                                            15000  21.0143   736080  1.7896  2760384
Symfony\Component\HttpKernel\Kernel->initializeContainer                                             1  0.0147  1717064  0.0099  1478920
DateTime::createFromFormat                                                                       15000  1.1265   960000  1.1265   960000
Monolog\Handler\FingersCrossedHandler->isHandling                                                15000  0.9998   720000  0.9998   720000
Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy->isHandlerActivated                  15000  1.0250   720000  1.0250   720000
include                                                                                            245  0.3669  2722152  0.0159   509520
FilesystemIterator->current                                                                         85  0.0058   383728  0.0058   383728
Symfony\Component\Finder\Expression\Regex::create                                                   30  0.0296   380840  0.0105   351632
appProdProjectContainer->getDefaultParameters                                                        1  0.0002   179504  0.0002   179504
composerRequireee80ec58e11a2d87b2e216687850288a                                                      8  0.0186   288168  0.0125   162928
Symfony\Component\Finder\Adapter\PhpAdapter->searchInDirectory                                      15  0.1565   348440  0.0056    76840
ComposerAutoloaderInitee80ec58e11a2d87b2e216687850288a::loadClassLoader                              1  0.0011    63872  0.0010    63824
appProdProjectContainer->__construct                                                                 1  0.0008   237344  0.0003    57712
strtr                                                                                              639  0.0421    41256  0.0421    41256
substr                                                                                             765  0.0475    33600  0.0475    33600
Symfony\Component\Finder\Finder->addAdapter                                                         45  0.0242    34840  0.0075    31240
explode                                                                                             88  0.0053    30936  0.0053    30936
Symfony\Component\Finder\Finder->Symfony\Component\Finder\{closure}                                135  0.0089    29928  0.0089    29928
Composer\Autoload\ClassLoader->set                                                                  53  0.0038    29928  0.0038    29928
require_once                                                                                         5  0.0477   719696  0.0009    29080
FilterIterator->key                                                                                248  0.0200    27688  0.0200    27688
stream_get_meta_data                                                                                17  0.0010    24752  0.0010    24752
Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator->__construct                       15  0.0172    29520  0.0082    23280
ReflectionClass->getConstructor                                                                     74  0.0047    23096  0.0047    23096
str_replace                                                                                        113  0.0070    22448  0.0070    22448
Symfony\Component\Console\Input\InputDefinition->setArguments                                      109  0.0405    32168  0.0159    22328
Symfony\Component\Console\Input\InputDefinition->setOptions                                        108  0.0707    37224  0.0120    21552
ReflectionClass->__construct                                                                        82  0.4401  3963992  0.0088    21024
preg_match                                                                                        1061  0.0719    20400  0.0719    20400
Symfony\Component\Console\Input\InputOption->isArray                                               412  0.0253    19776  0.0253    19776
array_merge                                                                                         32  0.0019    19712  0.0019    19712
Symfony\Component\Console\Application->add                                                          76  0.1666   504288  0.0231    19584
Symfony\Component\Console\Command\Command->__construct                                              76  0.5897   560088  0.0121    19112
ReflectionClass->newInstance                                                                        74  0.5825   572240  0.0080    19056
RecursiveDirectoryIterator->hasChildren                                                             85  0.0574    18216  0.0574    18216
SplFileInfo->__construct                                                                            85  0.0065    16528  0.0065    16528
Symfony\Component\Finder\Finder->__construct                                                        15  0.0938   349816  0.0089    16208

Any help would be much appreciated,
Tibor

Exclude 403 (4XX) Errors from the Log

Hello.

If I throw a Symfony\Component\Security\Core\Exception\AccessDeniedException
or a Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException I do not want a log about this exception, because I thrown it.

For the security, The Symfony\Component\Security\Core\Exception\AccessDeniedException is converted to a Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException in the Symfony\Component\Security\Http\Firewall\ExceptionListener::handleAccessDeniedException.

I think we can extends the configuration to all kind of exception in the namespace Symfony\Component\HttpKernel\Exception\*, because If I throw an HttpKernel exception, it don't want a log.

What do you think ?

Profiler enabled check in DebugHandlerPass doesn't work correctly

The DebugHandlerPass checks if the profiler is enabled, but I think that this check is incomplete. I'm running a Symfony 2.2 instance and even in production mode the profiler section is defined in the config, only the profiler.enabled option is set to false to disable the profiler.

I think that the DebugHandlerPass class should check if the enabled is set to true and only then add the DebugHandler. Or is there something I'm missing?

excluded_404s and rotating_file

I'm trying to use excluded_404s with rotating_file

monolog:
. . . . handlers:
. . . . . . . . main:
. . . . . . . . . . . . type: rotating_file
. . . . . . . . . . . . action_level: ERROR
. . . . . . . . . . . . path: "%kernel.logs_dir%/%kernel.environment%.log"
. . . . . . . . . . . . max_files: 10
. . . . . . . . . . . . handler: grouped
. . . . . . . . . . . . excluded_404s:
. . . . . . . . . . . . . . . . - ^/*
. . . . . . . . . . . . channels: !doctrine

I still got NotFoundHttpException in my logs, what did I miss ?

Invalid handler type "console" given for handler "console"

After installing Symfony Standard Edition and updating it to 2.3.2 using php composer.phar update and got the following error when clearing the cache:

[InvalidArgumentException]                                  
  Invalid handler type "console" given for handler "console" 

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception

just running php app/console trigger the same error

I've tried to downgrade to 2.3.1 but have the same error.
I believe this is related to this PR: #42

The exact exception I have is the following:

InvalidArgumentException: Invalid handler type "console" given for handler "console"

in /var/www/symfony/vendor/symfony/monolog-bundle/Symfony/Bundle/MonologBundle/DependencyInjection/MonologExtension.php line 308
at MonologExtension->buildHandler(object(ContainerBuilder), 'console', array('type' => 'console', 'bubble' => false, 'priority' => '0', 'level' => 'DEBUG', 'path' => '%kernel.logs_dir%/%kernel.environment%.log', 'ident' => false, 'logopts' => '1', 'facility' => 'user', 'max_files' => '0', 'action_level' => 'WARNING', 'activation_strategy' => null, 'stop_buffering' => true, 'buffer_size' => '0', 'title' => null, 'members' => array(), 'to_email' => array(), 'content_type' => null)) in /var/www/symfony/vendor/symfony/monolog-bundle/Symfony/Bundle/MonologBundle/DependencyInjection/MonologExtension.php line 51
at MonologExtension->load(array(array('handlers' => array('main' => array('type' => 'stream', 'path' => '/var/www/symfony/app/logs/dev.log', 'level' => 'debug'), 'console' => array('type' => 'console', 'bubble' => false)))), object(ContainerBuilder)) in /var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php line 50
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in /var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php line 39
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in /var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php line 119
at Compiler->compile(object(ContainerBuilder)) in /var/www/symfony/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php line 559
at ContainerBuilder->compile() in /var/www/symfony/app/bootstrap.php.cache line 659
at Kernel->buildContainer() in /var/www/symfony/app/bootstrap.php.cache line 595
at Kernel->initializeContainer() in /var/www/symfony/app/bootstrap.php.cache line 380
at Kernel->boot() in /var/www/symfony/app/bootstrap.php.cache line 411
at Kernel->handle(object(Request)) in /var/www/symfony/web/app_dev.php line 28

"formatter" option for type "service" doesn't work

Looking at the code I see that there is a return immediately after the service alias is created. Should not be also possible to override whichever formatter the service has to a custom one?

My use case is with the SncRedisBundle, where no formatter is set for the service and monolog doesn't call the setFormatter method either.

Thanks!

Error: "You have requested a synthetic service ("request")." when using excluded_404s

Whey I configure the bundle to use excluded_404s for a fingers_crossed handler I get the following error:

RuntimeException in ContainerBuilder.php line 915:
You have requested a synthetic service ("request"). The DIC does not know how to construct this service.

When looking in the code, I think this causes the error (MonologExtension.php line 293-298)

} elseif (!empty($handler['excluded_404s'])) {
    $activationDef = new Definition('%monolog.activation_strategy.not_found.class%', array($handler['excluded_404s'], $handler['action_level']));
    $activationDef->addMethodCall('setRequest', array(new Reference('request', ContainerInterface::NULL_ON_INVALID_REFERENCE, false)));
    $container->setDefinition($handlerId.'.not_found_strategy', $activationDef);
    $activation = new Reference($handlerId.'.not_found_strategy');
} else {

I'm using symfony 2.6.7 with monolog-bundle 2.7.1

My guess is that the MonologExtension should use the request stack, but that might not be compatible with older versions of symfony.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.