Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention monolog service name in the monolog cookbook #2151

Closed
weaverryan opened this issue Jan 17, 2013 · 2 comments
Closed

Mention monolog service name in the monolog cookbook #2151

weaverryan opened this issue Jan 17, 2013 · 2 comments
Labels
good first issue Ideal for your first contribution! (some Symfony experience may be required)

Comments

@weaverryan
Copy link
Member

In the cookbook article where we introduce monolog, we don't ever say how to get it out of the container. We should show a quick example of logging from within a controller, which will show that the service is called logger.

@wouterj
Copy link
Member

wouterj commented Jan 17, 2013

I think we already have this in the first example of cookbook/logging/monolog:

$logger = $this->get('logger');
$logger->info('I just got the logger');
$logger->err('An error occurred');

It is not very clear that this is from inside a controller, we can do something like this:

# src/Acme/DemoBundle/Controller/LogController.php
namespace Acme\DemoBundle\Controller;

// ...
class LogController extends Controller
{
    public function logAction()
    {
        $logger = $this->get('logger');
        $logger->info('I just got the logger');
        $logger->err('An error occurred');
    }
}

@weaverryan
Copy link
Member Author

Ah, thanks @wouterj! I don't know how I missed that :). I just moved some things around in #2154

Thanks!

weaverryan added a commit that referenced this issue Jan 30, 2013
[#2151] Reorganizing part of the monolog cookbook to put usage first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Ideal for your first contribution! (some Symfony experience may be required)
Projects
None yet
Development

No branches or pull requests

2 participants