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

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

Open
firaskanaan93 opened this issue Oct 24, 2023 · 11 comments
Open

Comments

@firaskanaan93
Copy link

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

@arukompas
Copy link
Contributor

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!

@firaskanaan93
Copy link
Author

@arukompas here you are
image
full-2023-10-31 (1).log

@arukompas
Copy link
Contributor

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

Let me know!

@firaskanaan93
Copy link
Author

same issue
image

@arukompas
Copy link
Contributor

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.

@firaskanaan93
Copy link
Author

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

@arukompas
Copy link
Contributor

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

@eriq123
Copy link

eriq123 commented Dec 20, 2023

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

@arukompas
Copy link
Contributor

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.

@Taoshan98
Copy link

Any update?

@arukompas
Copy link
Contributor

@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!

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

4 participants