2015-03-05 12:38
浏览 129


I have a problem with my project, I want to use Monolog to write the logs and I can't do. So, I created an service :

  class: Monolog\Logger
  arguments: [Debug]
    - [pushHandler, [@my_log_handler]]

   class: Monolog\Handler\StreamHandler
   arguments: [/home/vagrant/Workspace/symfony/app/logs/test.log, 100]

My controller :

    $em = $this->getDoctrine()->getManager();
    $categories = $em->getRepository('EnsJobeetBundle:Category')->getWithJobs();

If I write :

$logger = $this->get('my_logger');
$logger->info('Test log');

The logs is inserted in test.log

If I write :

$logger = $this->get('my_logger');

The logs doesn't write. I get the error 500. Please help me. Thx in advance!!! Errors :

2015/03/05 12:58:48 [error] 4698#0: *76 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 532676608 bytes) 

PHP message: PHP   8. print_r() /home/vagrant/Workspace/symfony/src/Ens  /JobeetBundle/Controller/JobController.php:34" while reading response header  from upstream, client:, server:, request: "GET
/job/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: ""
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • duanfu9523 2015-03-05 14:31

    You're running out of memory trying to process the array. That could be for many reasons, maybe it's just too big, maybe it has recursive aspects, etc.

    A good trick when working with this is to just print the keys. You will see less data, but you will be much less likely to surpass your memory limits. When you get a look at your array, then you can print specific parts of it after you have a look at the keys. Try this:

    $logger = $this->get('my_logger');

    Your other alternative, if you really need to see the whole array, it to increase your memory limits in php.ini. Look for a line like this to change them:

    memory_limit = 128MB
    解决 无用
    打赏 举报

相关推荐 更多相似问题