Monolog is a logging library for PHP 5.3 used by Symfony2. It is inspired by the Python LogBook library.
Questions tagged [monolog]
514 questions
77
votes
6 answers
How to Log INFO to separate file in Laravel
How to specify a separate file for logging INFO in Laravel 5.1?

Debug Diva
- 26,058
- 13
- 70
- 123
57
votes
3 answers
How to write logs from one service into separate file?
Normally you just get logger service, and logs go to:
%kernel.root_dir%/%kernel.environment%.log
I would like to log messages form SOAP services ONLY to:
%kernel.root_dir%/%kernel.environment%.soap.log
not to main logfile.
I've read the cookbook,…

canni
- 5,737
- 9
- 46
- 68
49
votes
9 answers
Logging full stack trace with Monolog
I use Monolog as a stand-alone library in my application and recently I ran into an issue. Let's say, at some point in my application I catch an exception and I want to log it:
$mylogger->error('Exception caught', array('exception' =>…

Wild One
- 751
- 1
- 5
- 11
47
votes
2 answers
PHP: How to use monolog to log to console (php://out)?
I just switched to monolog and wanted to log my message to the PHP console instead of a file. This might seem obvious for some people, but it took me a little while to figure out how to do that and I couldn't find a similar question/answer on…

Hirnhamster
- 7,101
- 8
- 43
- 73
26
votes
2 answers
Log rotating with Monolog in Symfony2
I'd like to know if there's any possibility to configure Monolog in Symfony2 to create a new log file every day, for example : 2013-11-21-prod.log.

mneute
- 686
- 1
- 6
- 14
24
votes
4 answers
How not to show last bracket in a monolog log line?
// in my PHP code
$log = new Logger('LaurentCommand');
$log->pushHandler(new StreamHandler('./app/logs/LaurentCommand.log'));
$log->addInfo("Start command",array('username' => 'Joe', 'Age' => '28'));
Result in log file LaurentCommand.log…

stloc
- 1,508
- 1
- 16
- 26
22
votes
2 answers
Custom monolog handler for default monolog in Symfony 2
I want to add a custom handler to a default monolog in Symfony 2.
In my config.yaml file, I have:
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
…

TroodoN-Mike
- 15,687
- 15
- 55
- 78
16
votes
2 answers
How to get Doctrine to log queries in Symfony2
I'm pretty new to Symfony2, and I'm looking for a way to log SQL queries (including timings) to the same log file as the rest of my application.
From what I can determine from the documentation this should all work out of the box, but after a few…

Andy Raines
- 297
- 1
- 3
- 9
15
votes
2 answers
How to log multiline entries with monolog like a formatted array?
I am trying to log an array with monolog in symfony.
$logger = $this->get('logger');
$logger->info(=print_R($user,true));
the output i get is not formatted as a print_r would be expected. It logs it all on one line.
I do not have any monolog…

Chris
- 2,166
- 1
- 24
- 37
13
votes
2 answers
Symfony 2 : Log into a specific file
I searched a lot before posting my question. I didn't find a clear answer, so here it is.
I want to log messages in a different log file as dev.log or prod.log. I mean a file which won't be poluted by Symfony core messages. I heard about logger and…

frinux
- 2,052
- 6
- 26
- 47
13
votes
9 answers
Symfony autowiring monolog channels
Following this documentation, I can create many channels which will create services with the following name monolog.logger.
How can I inject these services into my service with DI injection and autowiring ?
class FooService
{
…

Fabien Papet
- 2,244
- 2
- 25
- 52
13
votes
2 answers
How to do advanced filtering of Monolog messages in Symfony?
I am using the MonologBundle in my Symfony 2.8 project to manage log messages. Using different Handlers it is no problem to write logs to file and to send them by e-mail at the same time.
I would like to reduce the number of messages I receive by…

Andrei Herford
- 17,570
- 19
- 91
- 225
12
votes
5 answers
How to exclude deprecation messages from logs in Symfony 4?
I have migrated an application from Symfony 3.4 to Symfony 4.4.
Now I have a lot of deprecations for each request/ Sf command (I can't fix that deprecations).
How can I exclude deprecations from the log for this Symfony App?

acantepie
- 329
- 1
- 3
- 9
12
votes
1 answer
Adding filename and line number to Monolog output
Couldn't find a way to add a the file name and the line number from which the log function was called.
I'm using a simple StreamHandler:
$this->log = new Logger('APP');
$this->log->pushHandler(new StreamHandler('/logs/app.log', Logger::DEBUG));
and…

asmadeus
- 121
- 6
12
votes
3 answers
How to assert a line is logged using Monolog inside Symfony
I'm using Monolog inside Symfony2, using the default MonologBundle. I'm trying to assert inside my tests, that a line is logged. I've configured this in my config_test.yml:
monolog:
handlers:
main:
type: test
…

hvtilborg
- 1,397
- 11
- 21