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

Errors not logged #255

Closed
Nex-Otaku opened this issue Mar 3, 2021 · 13 comments
Closed

Errors not logged #255

Nex-Otaku opened this issue Mar 3, 2021 · 13 comments
Labels
status:ready for adoption Feel free to implement this issue. type:bug Bug

Comments

@Nex-Otaku
Copy link
Contributor

Nex-Otaku commented Mar 3, 2021

Application does not log errors.

Update 2021-03-16:
Web application with disabled SQlite PHP extension throws error that is not logged.
Console application does not log error on any exception.

What steps will reproduce the problem?

Throw any exception in application code, for example \RuntimeException

What is the expected result?

Error appears in log file: /runtime/logs/app.log

What do you get instead?

No errors in log

Additional info

  1. Errors are not logged in both console and web.

  2. In Yii2 basic application, application errors are logged by default.

Q A
Version 1.0.?
PHP version 7.4
Operating system WSL
@samdark samdark added status:to be verified Needs to be reproduced and validated. type:bug Bug labels Mar 3, 2021
@devanych
Copy link
Member

devanych commented Mar 4, 2021

Checked, all errors are logged out of the box. Please check your logger configuration.

@Nex-Otaku
Copy link
Contributor Author

@devanych no changes made to configuration, clean demo install.

@devanych
Copy link
Member

devanych commented Mar 4, 2021

Very strange :)

If I have logs, and you do not, then this is not a logger's problem. Maybe the problem is the rights to the runtime folder, you could try changing the rights to 0777 and try again?

@Nex-Otaku
Copy link
Contributor Author

@devanych no problems with folders, code just doesnt get executed.

@Nex-Otaku
Copy link
Contributor Author

@devanych make a clean app install and check.

@BoShurik
Copy link

BoShurik commented Mar 9, 2021

Can't reproduce

// \App\Controller\SiteController
public function index(): ResponseInterface
{
    throw new \RuntimeException('test');

    return $this->viewRenderer->render('index');
}

produces in runtime/logs/app.log

2021-03-09 11:52:25.253000 [error][application] RuntimeException with message 'test' 

@devanych
Copy link
Member

devanych commented Mar 9, 2021

@Nex-Otaku I also have everything working correctly, as well as @BoShurik. Both on localhost and in docker.

@samdark
Copy link
Member

samdark commented Mar 10, 2021

That should be something very specific to @Nex-Otaku environment. I'm afraid we can't fix it since we have no such environment. @Nex-Otaku in case you'll find out the details, let us know.

@samdark samdark closed this as completed Mar 10, 2021
@Nex-Otaku
Copy link
Contributor Author

Experimented with it a bit.

Application does log errors in web mode, but not in all cases, and does not log errors in console mode at all.

Steps to reproduce on Ubuntu 20.04, PHP 7.4 (WSL).

Web:

  1. Install clean new demo app
    composer create-project --prefer-dist --stability=dev yiisoft/yii-demo yii3-demo-logging-errors
    cd yii3-demo-logging-errors

  2. Turn off pdo_sqlite
    sudo phpdismod pdo_sqlite

  3. Restart FPM
    sudo service php7.4-fpm restart

  4. Run app (kill it and restart if already running)
    composer run serve > ./runtime/yii.log 2>&1 &

  5. Check blog page response, should give 500 because SQlite is disabled.
    curl -s -i http://127.0.0.1:8080/blog | head -1

  6. Check logs in runtime/app.log - no errors there!

Console:

  1. Install clean new demo app
    composer create-project --prefer-dist --stability=dev yiisoft/yii-demo yii3-demo-logging-errors
    cd yii3-demo-logging-errors

  2. Add exception to App\Command\Router\ListCommand::execute()
    throw new \RuntimeException("You would not see that in log");

  3. Run console command
    vendor/bin/yii router/list

  4. See error message in console output...

  5. But not in log! runtime/app.log

@samdark samdark reopened this Mar 16, 2021
@samdark samdark removed the status:to be verified Needs to be reproduced and validated. label Mar 22, 2021
@samdark samdark added the status:ready for adoption Feel free to implement this issue. label Mar 22, 2021
@samdark
Copy link
Member

samdark commented Mar 22, 2021

It happens because Cycle tried to read SQLite schema during container initializaition before fully configured logger replaces initial one:

@samdark
Copy link
Member

samdark commented Mar 22, 2021

We've fixed web app case and threre is a separate issue for console: yiisoft/yii-console#110

@samdark samdark closed this as completed Mar 22, 2021
@Nex-Otaku
Copy link
Contributor Author

Nex-Otaku commented Mar 24, 2021

Checked web application, errors are logged correctly to /runtime/logs/app.log. Thanks.

@rustamwin
Copy link
Member

Fixed for console application as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:bug Bug
Projects
None yet
Development

No branches or pull requests

5 participants