opcodesio/log-viewer

Log with name access-*.log showing "No results"

Closed this issue · 1 comments

I'm sorry if my english is not good

Log with name like "access-2024-01-05.log" showing "No results"

image

but the problem is resolved if we just rename that file to "acccess-2024-01-05.log" add new "c" character.

image

and here is my config file:

<?php

return [

    'enabled' => env('LOG_VIEWER_ENABLED', true),

    'route_domain' => null,

    'route_path' => 'log-viewer',

    'back_to_system_url' => config('app.url', null),

    'back_to_system_label' => null, // Displayed by default: "Back to {{ app.name }}"

    'timezone' => null,

    'middleware' => [
        'web',
        'auth',
        \Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class,
        'accessLog'
    ],

    'api_middleware' => [
        \Opcodes\LogViewer\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
        \Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class,
    ],

    'hosts' => [
        'local' => [
            'name' => ucfirst(env('APP_ENV', 'local')),
        ],

        // 'staging' => [
        //     'name' => 'Staging',
        //     'host' => 'https://staging.example.com/log-viewer',
        //     'auth' => [      // Example of HTTP Basic auth
        //         'username' => 'username',
        //         'password' => 'password',
        //     ],
        // ],
        //
        // 'production' => [
        //     'name' => 'Production',
        //     'host' => 'https://example.com/log-viewer',
        //     'auth' => [      // Example of Bearer token auth
        //         'token' => env('LOG_VIEWER_PRODUCTION_TOKEN'),
        //     ],
        //     'headers' => [
        //         'X-Foo' => 'Bar',
        //     ],
        // ],
    ],

    'include_files' => [
        '*.log',
        '**/*.log',

        // You can include paths to other log types as well, such as apache, nginx, and more.
        '/var/log/httpd/*',
        '/var/log/nginx/*',

        // MacOS Apple Silicon logs
        '/opt/homebrew/var/log/nginx/*',
        '/opt/homebrew/var/log/httpd/*',
        '/opt/homebrew/var/log/php-fpm.log',
        '/opt/homebrew/var/log/postgres*log',
        '/opt/homebrew/var/log/redis*log',
        '/opt/homebrew/var/log/supervisor*log',

        // '/absolute/paths/supported',
    ],

    'exclude_files' => [
        // 'my_secret.log'
    ],

    'hide_unknown_files' => false,

    'shorter_stack_trace_excludes' => [
        '/vendor/symfony/',
        '/vendor/laravel/framework/',
        '/vendor/barryvdh/laravel-debugbar/',
    ],

    'cache_driver' => env('LOG_VIEWER_CACHE_DRIVER', null),

    'lazy_scan_chunk_size_in_mb' => 200,

    'strip_extracted_context' => false,
];

Hey @cevitaufik

Interesting problem! And I know why this happens 😄

access-... files are usually Apache/Nginx access logs, which have a slightly different structure. Log Viewer thinks it's Apache/Nginx (because of the file name), and then uses a specific RegEx for those files. But, it doesn't find any Apache/Nginx logs, and thus shows empty.

But it looks like the contents are actually Laravel logs, so an easy fix would be to name the files laravel-access-* for example.

In the future I'll add some way to identify and fix the file type the Log Viewer detects, because sometimes it can be wrong, as you can see.