magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

exception.log missing #36054

Closed siliconalchemy closed 1 year ago

siliconalchemy commented 2 years ago

Preconditions and environment

This Magento install has

Steps to reproduce

Trigger an exception/error (for example reCAPTCHA error detailed in #34975), or make generated/ directory read-only to trigger a read-only error.

Expected result

I expect to see an error and trace in var/log/exception.log

Actual result

No exception.log exists. Errors do seem to appear in system.log, but I don't know if they are everything that should be in exception.log.

Additional information

This instance of Magento has been updated since 2.0 to 2.2 and 2.4. In the past exception.log was always present with errors/exceptions.

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @siliconalchemy. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

amokato commented 2 years ago

We have the same issue since 2.4.3-p1 / 2.4.4

adriansanta commented 2 years ago

Same here. 2.4.4 EE. We suspect there is a gap between the preg_match used in module-support and some new log formatting. The matching expressions might need an update to start working correctly again.

kamephis commented 2 years ago

We tested that on a vanilla 2.4.4 (Community) in the exception.log is not written there. Would be nice to get some feedback from Magnet here. It's difficult to debug stuff when there is no clue about what happens.

amokato commented 2 years ago

Any updates on this? Nobody seems to care about such a severe issue.

hostep commented 2 years ago

@sdzhepa: can we have somebody to verify this? This indeed sounds like a P0 or P1 prio if it's true. Thanks!

I can not confirm that this is true on Magento 2.4.3-p3 on production shops of ours, it works as expected over there. We haven't tried 2.4.4 or 2.4.5 yet in production, so I can't speak about those versions yet.

amokato commented 2 years ago

We're having this issue on 2.4.4 (CE). It seems that some errors are written to the system.log.

kamephis commented 2 years ago

In our case the exceptions seem to be written into the system.log instead of the exception.log (2.4.4 CE). The exception.log stays empty.

m2-assistant[bot] commented 2 years ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 2 years ago

Verified the issue on fresh instance of 2.4.5 Project-community-edition and the issue is reproducible. exception.log file is missing in var/log folder. No errors are written into exception.log. Only all errors are written into system.log file. Note: There is no issue when the Magento is upgraded to 2.4.5 from 2.4.3 Project-community-edition. exception.log file is present in this case and all the errors/exceptions are getting written into exception.log file as expected. Hence confirming this issue.

github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6796 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 years ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

engcom-November commented 2 years ago

Hi @siliconalchemy , Reviewed the issue again and after internal discussion, it has been concluded that this is not an issue. Magento has changed the way to write into exception.log File. To print the log in exception.log, exception parameters must be given in context.

  1. $this->logger->critical($e, ['exception' => $e]);
  2. $this->logger->log('CRITICAL', $e->getMessage(), ['exception' => $e]); Kindly recheck and let us know if you are still facing any issues. Thank you.
siliconalchemy commented 2 years ago

@engcom-November - Ah! Haha that's a really funny april fools joke!!

Oh wait, it's the middle of October, it's not April 1st.

THIS IS A BUG var/log/exception.log is a well established log for critical errors. This is not about custom code/modules, user logging. This is fundamental, built in logging from standard usage of Magento. References to it are littered throughout the official Magento documentation. Have a look.
THIS IS A BUG

eg. https://devdocs.magento.com/cloud/project/log-locations.html Exception log: var/log/exception.log

https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/cli/configure-cron-jobs.html Jobs with an ERROR status are always logged as CRITICAL in <install_directory>/var/log/exception.log.

etc etc

adriansanta commented 2 years ago

100% agree with @siliconalchemy

Having all kind of log severities in the same file (system.log) really makes it difficult to use and defeats the purpose of log severity in the first place. We have to employ various workarounds (like parsing rules) to filter out "noise" lines in order to have a realistic overview of actual issues.

Furthermore, exception.log is not populated not only by custom/third party code, but also by Magento core code itself.

At least we could expect from core team to list this so-called "feature" in their release notes, as a backwards incompatible change. But ideally, this should be fixed to work as in the previous versions.

kamephis commented 2 years ago

I agree, this is by far not a feature. Please take your time and fix this. It has been month and nothing happened.

jurvi commented 2 years ago

Yes, we are also experiencing this same issue. So does 2.4.5 upgrade fix this?

briangmoore77 commented 2 years ago

This needs to be fixed asap. do you know how many sites are trying to get updated to 2.4.4 or 2.4.5 by 11/28? Lots... They all need that exception.log to be working like it is stated to work and how it has always worked.

engcom-November commented 2 years ago

Hello @siliconalchemy @adriansanta @kamephis @jurvi @briangmoore77, We have discussed this issue again internally and after further analysis came across the below commit: https://github.com/magento/magento2/commit/8e6aedc8130be01669b04f99c19ab3f48e4c0691 We are confirming this issue and further analysis is in progress. Thank you.

github-jira-sync-bot commented 2 years ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-6796

MeetKamal commented 2 years ago

Hello @engcom-November - We are facing same issue. Do we have any temp solution to enable exception.log, As lots of client facing issues.

jurvi commented 2 years ago

I would be also interested in a temp solution if such exists, two clients are now missing exception.log making problem debugging unnecessarily harder.

Shaikh-Samir commented 2 years ago

@MeetKamal

We have verified this issue in our local environment and found work around(temporary) solution for it.

File path where need to replace core code: vendor/magento/framework/Logger/Handler/System.php

Please replace below code:

public function write(array $record): void
    {
        if (isset($record['context']['exception'])) {
            $this->exceptionHandler->handle($record);

            return;
        }
        $record['formatted'] = $this->getFormatter()->format($record);

        parent::write($record);
    }

With :

public function write(array $record): void
    {

        if (isset($record['context']['exception']) || $record['level'] == Logger::CRITICAL) {
            $this->exceptionHandler->handle($record);

            return;
        }
        $record['formatted'] = $this->getFormatter()->format($record);

        parent::write($record);
    }
MeetKamal commented 2 years ago

Hi @Shaikh-Samir - Thank you for the Work around, Have tested and it seems working :)

briangmoore77 commented 1 year ago

Is this going backwards? I figured this would be fixed by now.

PaperDS commented 1 year ago

Still no exception.log in M2.4.5-p1

Shaikh-Samir commented 1 year ago

Still no exception.log in M2.4.5-p1

Hello @PaperDS We have tested this work around solution in M2.4.5-p1 as well and its working correctly in our project.

Thank you.

PaperDS commented 1 year ago

@

Still no exception.log in M2.4.5-p1

Hello @PaperDS We have tested this work around solution in M2.4.5-p1 as well and its working correctly in our project.

Thank you.

I've applied your work around and it works perfectly. Many thanks. I just don't like editing core code :-)

hostep commented 1 year ago

This might be fixed under ACP2E-1287: log exception to exception.log (untested), unfortunately no clean merge commit, so you'll probably want to add those 4 separate commits together in a patch.

Shaikh-Samir commented 1 year ago

@

Still no exception.log in M2.4.5-p1

Hello @PaperDS We have tested this work around solution in M2.4.5-p1 as well and its working correctly in our project. Thank you.

I've applied your work around and it works perfectly. Many thanks. I just don't like editing core code :-)

@PaperDS Yes got your point, its not best practice to edit in core code of framework, actually i also don't like to do this. So that mentioned it work around fix (as temporary solution). And if don't want to change in core magneto files then you can also create one patch for those changes and install.

onlinebizsoft commented 1 year ago

We also re-look at this one as well https://github.com/magento/magento2/issues/13128

engcom-Hotel commented 1 year ago

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket ACP2E-1287 by the internal team Related commits: https://github.com/magento/magento2/search?q=ACP2E-1287&type=commits

Based on the Jira ticket, the target version is 2.4.6.

Thanks

hostep commented 1 year ago

If anyone wants a patch based on the commits from above (which work on Magento 2.4.5, haven't tested on 2.4.4), this one can be applied against the magento/framework composer package: ACP2E-1287-Framework.txt

UglyWillDuckling commented 1 year ago

If anyone wants a patch based on the commits from above (which work on Magento 2.4.5, haven't tested on 2.4.4), this one can be applied against the magento/framework composer package: ACP2E-1287-Framework.txt

Thanks for the patch.

andy-igoo commented 1 year ago

Just a quick note to say this worked for me: https://magento.stackexchange.com/questions/361276/exception-log-is-missing-in-magento2-4-4

--- a/vendor/magento/framework/Logger/Handler/System.php
+++ b/vendor/magento/framework/Logger/Handler/System.php
@@ -55,7 +55,7 @@
      */
     public function write(array $record): void
     {
-        if (isset($record['context']['exception'])) {
+        if (isset($record['context']['exception']) || $record['level'] == Logger::CRITICAL) {
             $this->exceptionHandler->handle($record);

             return;
Eddcapone commented 1 year ago

@engcom-Hotel

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket ACP2E-1287 by the internal team Related commits: https://github.com/magento/magento2/search?q=ACP2E-1287&type=commits

Based on the Jira ticket, the target version is 2.4.6.

Thanks

Is there a patch available or do we have to wait until 2.4.6?

siliconalchemy commented 1 year ago

2.4.6 is out and includes this patch/fix.

Eddcapone commented 1 year ago

@siliconalchemy So we have to upgrade to 2.4.6 to fix it?

MeetKamal commented 1 year ago

Hi @Eddcapone - For the temp purpose you can try the below solution https://magento.stackexchange.com/questions/361276/exception-log-is-missing-in-magento2-4-4

We tried that and it seems working.

Eddcapone commented 1 year ago

@MeetKamal But this requires us to do a change in the core. Why is there no official patch?

vardhmankamani1 commented 1 year ago

@Eddcapone Here i am attach the patch file, you can use this patch untill the your system is not being updated to the 2.4.6 exception_log.zip

hostep commented 1 year ago

Or use my earlier referenced patch that is based on the official Adobe fix? (A lot time of could have been won if you just had read all the comments in this thread 😉)

Eddcapone commented 1 year ago

My question is wether there is an official patch and if not why not?

hostep commented 1 year ago

There isn't as far as I know, at least I can't find one when searching using their quality patches tool. As to why not, no idea, but probably Adobe didn't feel like it was important enough to create one...

So either take one of the solutions here from the thread, or make one yourself if you don't trust it (which is what I would recommend), or upgrade to 2.4.6-p1, or if you really want an official patch, create an issue or pull request here: https://github.com/magento/quality-patches (but knowing Adobe, it might take some weeks/months/years until you'll get one)

Eddcapone commented 1 year ago

@hostep, Thx! It is beyond me how there is no official patch for such an important bug CC @engcom-Hotel

Eddcapone commented 1 year ago

Or use my earlier referenced patch that is based on the official Adobe fix? (A lot time of could have been won if you just had read all the comments in this thread 😉)

I tried your patch. I copied it to vendor/magento/framework and executed git apply exception_loggin.patch. But the exception.log is still not getting generated even though I have a server error.

moazzama commented 10 months ago
diff --git a/vendor/magento/framework/Logger/Handler/System.php b/vendor/magento/framework/Logger/Handler/System.php
index ff57ae87..a6f6b91a 100644
--- a/vendor/magento/framework/Logger/Handler/System.php
+++ b/vendor/magento/framework/Logger/Handler/System.php
@@ -55,7 +55,7 @@ class System extends Base
      */
     public function write(array $record): void
     {
-        if (isset($record['context']['exception'])) {
+        if (isset($record['context']['exception']) || $record['level'] == Logger::CRITICAL) {
             $this->exceptionHandler->handle($record);

             return;
Eddcapone commented 10 months ago

Is there a patch already?

moazzamsali commented 10 months ago

Is there a patch already?

No I created the new one because on my site exception logs were not creating

Eddcapone commented 10 months ago

Why do they close it if there is no official patch?