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

Log file isn't created #7

Open
netdjw opened this issue Feb 7, 2024 · 14 comments
Open

Log file isn't created #7

netdjw opened this issue Feb 7, 2024 · 14 comments

Comments

@netdjw
Copy link

netdjw commented Feb 7, 2024

I made all steps from README, but log file isn't created so the package always show nothing on charts.

Isn't miss the documentation register a middleware or similar thing?

@mantas-done
Copy link
Owner

Hi @netdjw , middleware is registered automatically.
I have updated the code, please do: composer update
Now when you will visit /apm url, controller will show an error if it can't create /storage/app/apm folder. If that is the case, it means that file permissions are incorrect.
Please report whether you will get an error after the composer update.

@netdjw
Copy link
Author

netdjw commented Feb 10, 2024

Hi @mantas-done , I updated to v1.0.10, but still the same.

This is my config/apm.php:

<?php

return [
    /**
     * Enable or disable APM
     */
    'enabled' => env('MONITORING_APM', false),

    /**
     * How many results per page to show
     */
    'per_page' => 100,

    /**
     * Logs only part of requests. 1 - 100%, 0.1 - 10% of requests.
     */
    'sampling' => 1,

    /**
     * Log queries of pages that spent in SQL more than given seconds
     */
    'slow' => 3,
];

The storage/app/apm/ directory has 777 mod for testing.

I made a test exception in my code to verify the middleware is in the stacktrace and I see this:

Done \ LaravelAPM \ Middleware \ DelayedWriter: 12 handle

So the middleware is loaded just not write the log file.

@mantas-done
Copy link
Owner

mantas-done commented Feb 10, 2024 via email

@netdjw
Copy link
Author

netdjw commented Feb 17, 2024

Still not work. I tried with 'enabled', true and 1 values too.

I used dd to catch what methods are calling, but not called any method of any watcher. But DelayedWriter's handle method is called with this code:

    public function handle($request, Closure $next)
    {
        return $next($request);
    }

I think this isn't do anything.

LogWriter's methods also not called.

@netdjw
Copy link
Author

netdjw commented Feb 17, 2024

Sorry about slow replies, I'm was busy a while.

@mantas-done mantas-done reopened this Feb 20, 2024
@mantas-done
Copy link
Owner

image
DelayedWriter writes to file only after the user's request is returned. (terminate method)
Could you add Log::info('test'); into different places in code to check whether LogWriter::write(); is executed on your system?

@netdjw
Copy link
Author

netdjw commented Feb 20, 2024

I added and not executing.

@mantas-done
Copy link
Owner

Just making sure, you have looked into your log files? (because terminate method executes when the response is already sent to the browser and doing dd() or echo won't show up in the browser).

@kamilersz
Copy link

Got the same issue. Added Log::info('test'); in DelayedResponse, log test shown on file but no request apm is logged

@mantas-done
Copy link
Owner

Got the same issue. Added Log::info('test'); in DelayedResponse, log test shown on file but no request apm is logged

if possible, can you also add Log::info('test') inside the ::write() method and see where it gets stuck.
Whether it can't create a directory or file.
That would help me to fix this issue. Because I don't know how to reproduce this problem on my end.

@kamilersz
Copy link

it seems that the listener got registered here
$this->app['events']->listen(RequestHandled::class, [RequestWatcher::class, 'record']);

but RequestWatcher::class, 'record' method isn't called

@kamilersz
Copy link

It seems that I ran using laravel 5.3

by adding this, the requests are logged
$this->app['events']->listen('kernel.handled', [RequestWatcher::class, 'record']);

@mantas-done
Copy link
Owner

In composer.json, it requires at least Laravel 5.5.

@kamilersz
Copy link

don't know why my composer can install this though. but now works on my side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants