[2.2] some deprecations logs make my log file huge #7259

Closed
bamarni opened this Issue Mar 4, 2013 · 9 comments

Comments

Projects
None yet
4 participants
@bamarni
Contributor

bamarni commented Mar 4, 2013

When requesting a page on a staging server, apache returns a 500 because there is a huge log file being generated, the php memory limit is getting reached.

I can see the generated log file size is 170 Megabytes, even after deleting it and re-requesting, it fails again and regenerates this same huge log file.

It looks like it's because of some deprecation traces, they contain a long stack trace in JSON, is it intended?

For example this one :

[2013-03-04 16:57:52] deprecation.WARNING: UserPassword class in Symfony\Compone
nt\Security\Core\Validator\Constraint namespace is deprecated since version 2.2 
and will be removed in 2.3. Use the Symfony\Component\Security\Core\Validator\Co
nstraints\UserPassword class instead. {"type":-100,"stack":[{"function":"handle"
,"class":"Symfony\\Component\\HttpKernel\\Debug\\ErrorHandler","type":"->","args
":[16384,"UserPassword class in Symfony\\Component\\Security\\Core\\Validator\\C
onstraint namespace is deprecated since version 2.2 and will be removed in 2.3. 
Use the Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPassword
 class instead.","/home/acme.com/test/vendor/symfony/symfony/src/Symfony/Compon
ent/Security/Core/Validator/Constraint/UserPassword.php",25,{"options":"NULL"}]}
,{"file":"/home/acme.com/test/vendor/symfony/symfony/src/Symfony/Component/Secu
rity/Core/Validator/Constraint/UserPassword.php","line":25,"function":"trigger_e
rror","args":["UserPassword class in Symfony\\Component\\Security\\Core\\Validat
or\\Constraint namespace is deprecated since version 2.2 and will be removed in 2.3. Use the Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPassword class instead.",16384]},{"file":"/home/acme.com/test/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Form/Type/ProfileFormType.php","line":39,"function":"__construct","class":"Symfony\\Component\\Security\\Core\\Validator\\Constraint\\UserPassword","type":"->","args":[]},{"file":"/home/acme.com/test/src/Acme/UserBundle/Form/Type/ProfileFormType.php","line":15,"function":"buildForm","class":"FOS\\UserBundle\\Form\\Type\\ProfileFormType","type":"->","args":[{"username":"NULL","email":"NULL","country":"NULL","locality":"NULL","birthday":"NULL","sexe":"NULL","presentation":"NULL","avatar":"NULL","site":"NULL","site_description":"NULL","plainPassword":"NULL","plainPasswordConfirm":"NULL"},{"block_name":"NULL","data_class":"Acme\\UserBundle\\Entity\\User","empty_data":"[object] (Closure: {})","trim":"true","required":"true","read_only":"false","disabled":"false","max_length":"NULL","pattern":"NULL","property_path":"NULL","mapped":"true","by_reference":"true","error_bubbling":"true","label":"NULL","attr":[],"label_attr":[],"virtual":"false","compound":"true","translation_domain":"NULL","error_mapping":[],"validation_constraint":"NULL","constraints":[],"cascade_validation":"false","invalid_message":"This value is not valid.","invalid_message_parameters":[],"extra_fields_message":"This form should not contain extra fields.","post_max_size_message":"The uploaded file was too large. Please try to upload a smaller file.","csrf_protection":"true","csrf_field_name":"_token","csrf_provider":"[object] (Symfony\\Component\\Form\\Extension\\Csrf\\CsrfProvider\\SessionCsrfProvider: {})","intention":"profile","validation_groups":["Profile","Default"]}]},{"file":"/home/acme.com/test/vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php","line":167,"function":"buildForm","class":"Acme\\UserBundle\\Form\\Type\\ProfileFormType","type":"->","args":[{"username":"NULL","email":"NULL","country":"NULL","locality":"NULL","birthday":"NULL","sexe":"NULL","presentation":"NULL","avatar":"NULL","site":"NULL","site_description":"NULL","plainPassword":"NULL","plainPasswordConfirm":"NULL"},{"block_name":"NULL","data_class":"Acme\\UserBundle\\Entity\\User","empty_data":"[object] (Closure: {})","trim":"true","required":"true","read_only":"false","disabled":"false","max_length":"NULL","pattern":"NULL","property_path":"NULL","mapped":"true","by_reference":"true","error_bubbling":"true","label":"NULL","attr":[],"label_attr":[],"virtual":"false","compound":"true","translation_domain":"NULL","error_mapping":[],"validation_constraint":"NULL","constraints":[],"cascade_validation":"false","invalid_message":"This value is not valid.","invalid_message_parameters":[],"extra_fields_message":"This form should not contain extra fields.","post_max_size_message":"The uploaded file was too large. Please try to upload a smaller file.","csrf_protection":"true","csrf_field_name":"_token","csrf_provider":"[object] (Symfony\\Component\\Form\\Extension\\Csrf\\CsrfProvider\\SessionCsrfProvider: {})","intention":"profile","validation_groups":["Profile","Default"]}]},{"file":"/home/acme.com/test/vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php","line":126,"function":"buildForm","class":"Symfony\\Component\\Form\\ResolvedFormType","type":"->","args":[{"username":"NULL","email":"NULL","country":"NULL","locality":"NULL","birthday":"NULL","sexe":"NULL","presentation":"NULL","avatar":"NULL","site":"NULL","site_description":"NULL","plainPassword":"NULL","plainPasswordConfirm":"NULL"},{"block_name":"NULL","data_class":"Acme\\UserBundle\\Entity\\User","empty_data":"[object] (Closure: {})","trim":"true","required":"true","read_only":"false","disabled":"false","max_length":"NULL","pattern":"NULL","property_path":"NULL","mapped":"true","by_reference":"true","error_bubbling":"true","label":"NULL","attr":[],"label_attr":[],"virtual":"false","compound":"true","translation_domain":"NULL","error_mapping":[],"validation_constraint":"NULL","constraints":[],"cascade_validation":"false","invalid_message":"This value is not valid.","invalid_message_parameters":[],"extra_fields_message":"This form should not (...)

The strange thing is that I can't reproduce this locally, even with the same database dump than the staging server, both projects are to the same git hash and vendors installed from the same composer.lock file, but my local environment is not exactly the same so maybe it's related to a PHP/system setting?

@stof

This comment has been minimized.

Show comment Hide comment
@stof

stof Mar 4, 2013

Member

@Seldaek The handling of the exception key in the context may need to be improved in Monolog. This becomes visible now that Symfony starts using this PSR-3 convention to log exceptions.

Member

stof commented Mar 4, 2013

@Seldaek The handling of the exception key in the context may need to be improved in Monolog. This becomes visible now that Symfony starts using this PSR-3 convention to log exceptions.

@Seldaek

This comment has been minimized.

Show comment Hide comment
@Seldaek

Seldaek Mar 4, 2013

Member

What kind of improvements are you thinking of?

Member

Seldaek commented Mar 4, 2013

What kind of improvements are you thinking of?

@stof

This comment has been minimized.

Show comment Hide comment
@stof

stof Mar 4, 2013

Member

Well, probably avoiding to dump the whole stack trace in the LineFormatter but only the message (and the message of the previous exception) as stack traces tend to be very long.

Member

stof commented Mar 4, 2013

Well, probably avoiding to dump the whole stack trace in the LineFormatter but only the message (and the message of the previous exception) as stack traces tend to be very long.

@Seldaek

This comment has been minimized.

Show comment Hide comment
@Seldaek

Seldaek Mar 18, 2013

Member

Can you try with latest monolog see if it looks better? However I'm not sure if the message you were seeing came from monolog's serialization. Looks like it might be something symfony does when logging.

Member

Seldaek commented Mar 18, 2013

Can you try with latest monolog see if it looks better? However I'm not sure if the message you were seeing came from monolog's serialization. Looks like it might be something symfony does when logging.

@bamarni

This comment has been minimized.

Show comment Hide comment
@bamarni

bamarni Mar 19, 2013

Contributor

I've updated deps on the remote server, now monolog is at dd0b216e0229a24178c2f0782f8a7172c7ed1c96, I'm still getting this issue and a 170MB log file.

But actually I don't think it's because of monolog, the huge log file looks like a side effect of an infinite loop or something like that, I'm still under the impression I have the same issue than @craue in #7043.

I've also noticed another page where it happens, both of those pages are related to FOSUserBundle (registration page + edit user preferences page), unfortunately I can't investigate more than that as I can't reproduce it locally, it only occurs on the remote server.

Contributor

bamarni commented Mar 19, 2013

I've updated deps on the remote server, now monolog is at dd0b216e0229a24178c2f0782f8a7172c7ed1c96, I'm still getting this issue and a 170MB log file.

But actually I don't think it's because of monolog, the huge log file looks like a side effect of an infinite loop or something like that, I'm still under the impression I have the same issue than @craue in #7043.

I've also noticed another page where it happens, both of those pages are related to FOSUserBundle (registration page + edit user preferences page), unfortunately I can't investigate more than that as I can't reproduce it locally, it only occurs on the remote server.

@stof

This comment has been minimized.

Show comment Hide comment
@stof

stof Mar 19, 2013

Member

@bamarni note that FOSUserBundle should not trigger the deprecated error on these pages if you update the bundle to the latest version

Member

stof commented Mar 19, 2013

@bamarni note that FOSUserBundle should not trigger the deprecated error on these pages if you update the bundle to the latest version

@bamarni

This comment has been minimized.

Show comment Hide comment
@bamarni

bamarni Mar 19, 2013

Contributor

@stof : ok thx for the tip, but I can't do that currently, this was a 2.0 symfony application I had to upgrade, but I've noticed some sort of BC breaks when upgrading fosuserbundle to master, so I prefer stick it to 1.3 for now.

Contributor

bamarni commented Mar 19, 2013

@stof : ok thx for the tip, but I can't do that currently, this was a 2.0 symfony application I had to upgrade, but I've noticed some sort of BC breaks when upgrading fosuserbundle to master, so I prefer stick it to 1.3 for now.

@Seldaek

This comment has been minimized.

Show comment Hide comment
@Seldaek

Seldaek Apr 7, 2013

Member
Member

Seldaek commented Apr 7, 2013

fabpot added a commit that referenced this issue Apr 7, 2013

merged branch Seldaek/fix-deprecated-logs (PR #7587)
This PR was merged into the 2.2 branch.

Discussion
----------

[2.2][HttpKernel] Remove args from 5.3 stack traces to avoid filling log files

Fixes #7259 - it just makes the PHP 5.3 behavior match the one on 5.4.

Commits
-------

99256e4 [HttpKernel] Remove args from 5.3 stack traces to avoid filling log files, fixes #7259

@fabpot fabpot closed this Apr 7, 2013

fabpot added a commit that referenced this issue Apr 7, 2013

Merge branch '2.2'
* 2.2:
  Fix finding ACLs from ObjectIdentity's with different types
  [HttpKernel] tweaked previous merge
  #7531: [HttpKernel][Config] FileLocator adds NULL as global resource path
  Fix autocompletion of command names when namespaces conflict
  Fix timeout in Process::stop method
  fixed CS
  Round stream_select fifth argument up.
  Fix Process timeout
  [HttpKernel] Remove args from 5.3 stack traces to avoid filling log files, fixes #7259
  bumped Symfony version to 2.2.2-DEV
  updated VERSION for 2.2.1
  updated CHANGELOG for 2.2.1
  Fixed phpdoc blocks to show that $uri can be passed as a string or ControllerReference (rather than just as a string)
  [HttpFoundation] Fixed copy pasted comment from FlashBag in AttributeBag
  [FrameworkBundle] fixed the discovery of the PHPUnit configuration file when using aggregate options like in -vc app/ (closes #7562)
  [WebProfilerBundle] removed next pointer class in a template
  fix overwriting of request's locale if attribute _locale is missing

Conflicts:
	src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php
	src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php
	src/Symfony/Component/HttpKernel/Kernel.php
@bamarni

This comment has been minimized.

Show comment Hide comment
@bamarni

bamarni Apr 10, 2013

Contributor

it fixed my issue thx

Contributor

bamarni commented Apr 10, 2013

it fixed my issue thx

ostrolucky pushed a commit to ostrolucky/symfony that referenced this issue Mar 25, 2018

Merge branch '2.2'
* 2.2:
  Fix finding ACLs from ObjectIdentity's with different types
  [HttpKernel] tweaked previous merge
  #7531: [HttpKernel][Config] FileLocator adds NULL as global resource path
  Fix autocompletion of command names when namespaces conflict
  Fix timeout in Process::stop method
  fixed CS
  Round stream_select fifth argument up.
  Fix Process timeout
  [HttpKernel] Remove args from 5.3 stack traces to avoid filling log files, fixes #7259
  bumped Symfony version to 2.2.2-DEV
  updated VERSION for 2.2.1
  updated CHANGELOG for 2.2.1
  Fixed phpdoc blocks to show that $uri can be passed as a string or ControllerReference (rather than just as a string)
  [HttpFoundation] Fixed copy pasted comment from FlashBag in AttributeBag
  [FrameworkBundle] fixed the discovery of the PHPUnit configuration file when using aggregate options like in -vc app/ (closes #7562)
  [WebProfilerBundle] removed next pointer class in a template
  fix overwriting of request's locale if attribute _locale is missing

Conflicts:
	src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php
	src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php
	src/Symfony/Component/HttpKernel/Kernel.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment