log-viewer icon indicating copy to clipboard operation
log-viewer copied to clipboard

After swiching log-viewer, losing old logs

Open alpemreelmas opened this issue 1 year ago • 2 comments

Hello folks, Love to open source projects and would like to help to improve this project from a person who uses this package on the production.

Here is problem: After having log issue with the laravel.log file I've switched to the log-viewer, before I was using monolog. Everything was fine (at least I had my logs) after a moment, I realized that I can not see past logs such as 1 week ago.

  • I had over 300MB file before switching log-viewer, after I had max 100MB.

How I tried to find solution for this:

  • I thought this might be size of the file with the heavy logs, I have switched daily logs. Still there are missing parts in the day logs.
  • For example: 10/02/2025 there is only 40MB and I have 453 page. Oldest log that I have at 15:17, I have even daily job works at the morning.

Do you have any idea about it ?

Thank you even from now....

alpemreelmas avatar Feb 11 '25 13:02 alpemreelmas

Hey @alpemreelmas , sorry for the long time to respond. I really did not know what could be happening.

And to this day I can't see what could be happening in your case.

Log Viewer is simply that - a viewer for your logs. It does expose an endpoint to delete the log files, if you wish, but it deletes the whole file, not parts of it. You would also be able to see those requests in your Apache/Nginx access logs, so please double-check them in case a member of your team started deleting log files randomly.

If that is the case, you can disable log deletion by simply setting deleteLogFile Gate to return false:

    Gate::define('deleteLogFile', function (?User $user, LogFile $file) {
        // Do not allow deleting any of the log files via the UI or API calls.
        return false;
    });

Other than that, Log Viewer does not delete any log files, unless you run the Log Viewer's test suite in production (which you should never do). I doubt that you do, though.

So the only other place I would look at, if I were you, is your operating system's log rotation tools, such as Linux's "logrotate".

Hopefully this clears something up, or at least guides you in the right direction. Sorry I could not have been of more help!

arukompas avatar Mar 16 '25 11:03 arukompas

Hey @alpemreelmas , sorry for the long time to respond. I really did not know what could be happening.

And to this day I can't see what could be happening in your case.

Log Viewer is simply that - a viewer for your logs. It does expose an endpoint to delete the log files, if you wish, but it deletes the whole file, not parts of it. You would also be able to see those requests in your Apache/Nginx access logs, so please double-check them in case a member of your team started deleting log files randomly.

If that is the case, you can disable log deletion by simply setting deleteLogFile Gate to return false:

Gate::define('deleteLogFile', function (?User $user, LogFile $file) {
    // Do not allow deleting any of the log files via the UI or API calls.
    return false;
});

Other than that, Log Viewer does not delete any log files, unless you run the Log Viewer's test suite in production (which you should never do). I doubt that you do, though.

So the only other place I would look at, if I were you, is your operating system's log rotation tools, such as Linux's "logrotate".

Hopefully this clears something up, or at least guides you in the right direction. Sorry I could not have been of more help!

Hey @arukompas, thank you for your reply. Unfortunately none of them you mentioned above is not possible.

I'm the only developer and apart from me, nobody checks and manipulate logs.

Again thank you for your response. If I find anything related this issue, I'd like to contribute as an help.

alpemreelmas avatar Mar 19 '25 07:03 alpemreelmas