laravel-apm icon indicating copy to clipboard operation
laravel-apm copied to clipboard

Log file isn't created

Open netdjw opened this issue 1 year ago • 14 comments

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?

netdjw avatar Feb 07 '24 06:02 netdjw

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.

mantas-done avatar Feb 07 '24 14:02 mantas-done

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.

netdjw avatar Feb 10 '24 05:02 netdjw

Can you try setting 'enabled' to 'true' or adding to your .env file: MONITORING_APM=1

If that didn't work I will think of a better way to debug.

On Sat, Feb 10, 2024, 07:49 Balázs Winkler @.***> wrote:

Hi @mantas-done https://github.com/mantas-done , I updated to v1.0.10, but still the same.

This is my config/apm.php:

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. — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you were mentioned.Message ID: ***@***.***>

mantas-done avatar Feb 10 '24 05:02 mantas-done

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 avatar Feb 17 '24 09:02 netdjw

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

netdjw avatar Feb 17 '24 09:02 netdjw

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?

mantas-done avatar Feb 20 '24 04:02 mantas-done

I added and not executing.

netdjw avatar Feb 20 '24 07:02 netdjw

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).

mantas-done avatar Feb 20 '24 07:02 mantas-done

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

kamilersz avatar Aug 01 '24 07:08 kamilersz

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.

mantas-done avatar Aug 01 '24 07:08 mantas-done

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 avatar Aug 01 '24 07:08 kamilersz

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']);

kamilersz avatar Aug 01 '24 07:08 kamilersz

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

mantas-done avatar Aug 01 '24 07:08 mantas-done

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

kamilersz avatar Aug 02 '24 02:08 kamilersz