opcodesio/log-viewer

All records do not appear and when downloading the file they appear

firaskanaan93 opened this issue · 11 comments

All records do not appear and when downloading the file they appear
image

Hey @firaskanaan93

I won't have time to fix it this week, but can you first share the log file itself? As an attachment, not a code snippet please.

Thanks!

hey @firaskanaan93 , this might be fixed in v3.1.8 as I can no longer reproduce the issue in latest version.

Let me know!

same issue
image

hey @firaskanaan93 please clear the app cache (php artisan cache:clear) and let me know if that helps. Otherwise, try clearing the cache from the Log Viewer settings dropdown.

Hi @arukompas I try clear the cache but still same issue
image

@firaskanaan93 ok... Can you try using a different cache driver? You can see instructions here - https://log-viewer.opcodes.io/docs/3.x/configuration/result-caching

Please change it to redis or file, because the database cache driver might be broken in this case.

Let me know if this helps.

I experience the same issue, in the current project i'm working on we have a custom log formatter that modifies the log message like this [2023-12-20 06:35:10] local.DEBUG:Host:{HOST_ID}URL:http://example.com/ UserId: : {ERROR_MESSAGE}. Notice the lack of space between local.DEBUG: and Host:{HOST_ID}.

I was able to fix the no-result issue by adding a space in between for reading the future logs.

Is there a way to read the older logs with a different format specifically those without the space? I was reading about custom log types and I am not sure if that is the right concept to apply.

Update:
For projects with custom log message, here's what I did to fix mine.
TLDR: I followed the documentation in Default Log Types page

  • i created a class extending the LaravelLog class
<?php

namespace App\LogViewer;

use Opcodes\LogViewer\Logs\LaravelLog;

class CoreLaravelLog extends LaravelLog
{
    public static string $name = 'CustomLaravel';
    public static string $regex = '/\[(?P<datetime>[^\]]+)\] (?P<environment>\S+)\.(?P<level>\S+):\s*(?P<message>.*)/';
   // I just added \s* between the level colon and the message to allow logs with or without space/s
}

Note: I found the original regex on src\Logs\LaravelLog.php and updated it according to my needs.

  • register this class in my app\Providers\AppServiceProvider.php
use Opcodes\LogViewer\Facades\LogViewer;
use App\LogViewer\CoreLaravelLog;

class AppServiceProvider extends ServiceProvider
{
	/**
	 * Bootstrap any application services.
	 *
	 * @return void
	 */
	public function boot()
	{
          LogViewer::extend('laravel', CoreLaravelLog::class);
	}
...
}

hey @eriq123 , I'm aware it's currently a bit cumbersome to extend the default LaravelLog parser. I have it on my todo list, but at the moment you shouldn't extend the LaravelLog class.

Any update?

@Taoshan98 hey, could you please share whether:

  • you have extended the default Laravel log parser in Log Viewer
  • have different file name structure than the default Laravel (laravel-xxxx.log)

Thanks!