Log Viewer

License Latest Stable Version Total Downloads

Easily view your Flarum logfiles from within the admin interface.

This utility extension offers access to Flarum's logfiles without the need for command line access to your server. It exposes the contents of files found in the {flarum_install_dir}/storage/logs directly to the admin interface, or optionally via the API.

This is especially useful if you have either limited knowledge of SSH access/commands, or you are using a host where this is simply not permitted. So long as the Flarum logger has not been modified to store logs elsewhere (usually only on multi-instance, scalable hosting solutions), then this extension will work for you!

Need to access the logs in order to troubleshoot a problem you're having with your forum? Simply login as an admin account and look for any trouble signs in the log viewer. Simple, just be sure to review any log snippets you share with others, as they may contain sensitive data.

Subject to the Flarum scheduler being active, logfiles are purged from your log folder once they are more than 90 days old. A setting is provided to adjust this up/down to suit your requirements. A value of 0 will disable purging.

Screenshots

log viewer
log viewer mobile

API Usage

Two API endpoints are provided to enable the logs to be easily extracted from Flarum into another system. Permissions to access these endpoints are provided, and restriced to admin users only by default, although you may create a dedicated permission group and apply log access to that group as well for log retrieval without full admin permissions. NEVER GRANT LOG ACCESS TO REGULAR USERS.

Permission can be set within the extension page, or the global Permissions tab
permission

Once authenticated, a GET request can be made to /api/logs to list the available log files.

To retrieve a particular file, another GET request should be made to /api/logs/{filename}

Future changes/features

  • Add option to download a file from the admin interface
  • Add option to delete a file from the admin interface
  • Add feature to tail new logfile content and stream this into the viewer

Installation

Install with composer:

composer require ianm/log-viewer

Updating

composer update ianm/log-viewer
php flarum cache:clear

Thanks

A huge "thank you" must also go to @davwheat for his help in tweaking the CSS to get this into a good shape. 💝

Links

7 days later

0.1.1

  • Option to automatically clean up old log files after x days. 90 by default - no longer will your log folder fill up over time!

Subject to the Flarum scheduler being active, logfiles are purged from your log folder once they are more than 90 days old. A setting is provided to adjust this up/down to suit your requirements. A value of 0 will disable purging.

Updating
composer update ianm/log-viewer
php flarum cache:clear

Simply a must-have for developers. Doubly so if you are a prolific error producer such as I. Bravo!

8 months later

The log-viewer is not displaying any log files. As I do not have SSH access to where our forum is hosted, I had the site administrator check permissions on the logfiles; I have been advised the permission should allow the extension to access and read the log files.

I am using a Chrome browser, using Developer Tools I was able to locate an error message: all.css:1 Failed to load resource: net::ERR_BLOCKED_BY_RESPONSE.NotSameOrigin As the error appears to be browser related, I have disabled all extensions in the browser as well as allowing everything from the forum. The problem persists. I have tried another browser (Microsoft Edge) with the same result.

Deanna

  • DCar replied to this.

    DCar As an update, the log viewer is now functioning ~ it appears an error condition must be 'tripped' for a log entry to be created.

    10 months later

    It's saying "You do not have permission to do that"

    16 days later

    @IanM I am unable to view logs. I get the below errors. I can view files that are two days old and older only.

    No extra notes when in debug mode, and nothing in logs either.

    a month later

    Currently having an issue of not being able to view log contents. This is on a fresh install.

      2 months later

      I have the same problem as @fragicide & @treyb and I figured it only affects the logs that start with output-* instead of flarum-*

      and looking via FTP to the logs folder, all the flarum-* logs are directly in that folder but the output-* ones are in a /composer/ subfolder and that's what's maybe causing the not found error. My "output-*" logs are generated by the Extension Manager.

        11 days later

        Walid I figured it only affects the logs that start with output-* instead of flarum-*

        TeamF Other logs are working

        Same here

        3 months later
        a month later

        Hi Everyone,
        I need some assistance here
        @IanM kindly assist, or is this is the same issue as opened on github? If yes, i shall just wait for a fix then.