Package

Syonix Monolog Viewer

An easy-to-use viewer for log files generated by Monolog (https://github.com/Seldaek/monolog)

Package

syonix/monolog-viewer

View on GitHub →

Monolog Viewer

A viewer to nicely display log files generated by Monolog.

Mockup Credits

Installation & Setup

  1. Download Composer
  2. Execute php composer.phar create-project syonix/monolog-viewer install-directory/ (make sure to replace install-directory with the name of the directory you want to install monolg viewer into.
  3. Upload the files to your webspace
  4. Make sure PHP has write access to the directory /app/config/secure - This is where the password hash will be stored (see below). Write access can be achieved by either changing the folder's chmod to 777 (less secure) or making sure that the owner of the file is the same as the one the server is using.
  5. Create a configuration file (rename or copy the config_example.yaml).
  6. Open Monolog Viewer in the browser
  7. Enter a password of your choice twice and click "Create login".
  8. Done. You can now log in and use your installation of Monolog Viewer

MonologViewer requires PHP 5.5 or higher. If you are using Apache, make sure to enable the mod_rewrite module.

For configuration under nginx please refer to issue #14

Configuration

The config file is a YAML file containing the paths to your log files. Log files can be grouped. These groups are called clients, but you could also see them as sites or whatever makes sense to you.

To set up log files, make sure to fill in the config file following this structure:

debug: false
timezone: "Europe/Zurich"
dateFormat: d.m.Y, H:i:s
logs:
    Demo:
        Demo-Log-File:
            type: local
            path: /path/to/your/monolog-viewer/installation/test/SyonixLogViewer/res/test.log
    Acme:
        Acme App:
            type: ftp
            host: acme.com
            username: logs
            password: $upersecur3
            path: app/logs/prod.log

The field type determines how the app will try to access the log file. For this, Flysystem is used. Currently implemented are local and ftp, but any other Flysystem Adapter can easily be added to the Syonix\LogViewer\LogFile.php constructor. Feel free to contribute.

Note: If your config.yaml is invalid, Monolog Viewer will display an error message. Also, if a client does not contain any logs, the client will not be listed in the navigation. If your config file is invalid and you don't know why, check if there are any tab characters in it.

Configuration values

The following configuration values are available:

Name Type Description
timezone string Timezone string according to PHP Manual.
date_format string Date format for log entries according to the Angular JS Manual.
logs array List of all log files, categorized by "clients" (see above)
display_logger boolean Turn log channel (logger) display in log view on or off

Flysystem Types

local

Accesses log files on the server's local file system.

Config values Description
path The absolute file path. (You can use PHP's realpath() to get the absolute path of a file.)
ftp

Accesses log files via FTP.

Config values Description
host The host to connect to (e.g. ftp.acme.com)
username The ftp user to connect with
password The ftp user's password.
path The file path, relative to the FTP user's root directory.
port The port to use for connecting (optional, default: 21)
passive Use a passive connection (optional, default: true)
ssl Use an encrypted connection / FTP over SSL (optional, default: false)
timeout The default timeout (optional, default: 30)
sftp

Accesses log files via SFTP.

Config values Description
host The host to connect to (e.g. ftp.acme.com)
username The ftp user to connect with
password The ftp user's password.
port The port to use for connecting (optional, default: 21)
passive Use a passive connection (optional, default: true)
ssl Use an encrypted connection / FTP over SSL (optional, default: false)
timeout The default timeout (optional, default: 30)
private_key Path to the client private key (optional, no default)
All types
Config values Description
pattern A regex for a custom log line pattern.
For example if your log lines don't end in [] {} you could use /\[(?P<date>.*)\] (?P<logger>\w+).(?P<level>\w+): (?P<message>[^\[\{]+)/

Password management

My goal was to keep this tool so simple, that it can be installed on any shared hosting. Therefore I decicded not to use a database to store the password. Instead it is saved within a folder that is protected by a .htaccess file and therefore not accessible by the public.

The only way to get the password hash is via FTP and even if someone gets the file, it is still hashed using PHPs password_hash() function. If you use a secure password, this is pretty safe.

Multiple users might be implemented in the future.

Change password

To change your password, simply delete the /app/config/secure/passwd file and open Monolog Viewer to set a new password.

Mobile devices

The App is fully optimized for tablets and smart phones and can even be installed to the home screen on iOS devices. It then works like a native app and features an app icon as well as a beautiful splash screen.

Enforcing HTTPS

This should be done on a server configuration level. You could for example add this to the .htaccess file, right below RewriteEngine On:

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Syonix Monolog Viewer Related Articles

Split Log Levels Between Stdout and Stderr With Laravel image

Split Log Levels Between Stdout and Stderr With Laravel

Read article
Beautiful Log Viewer for Laravel image

Beautiful Log Viewer for Laravel

Read article
Tailwind Configuration Viewer image

Tailwind Configuration Viewer

Read article
Pan Analytics Viewer image

Pan Analytics Viewer

Read article
Statamic Mailables Viewer Previews Laravel Emails in the Control Panel image

Statamic Mailables Viewer Previews Laravel Emails in the Control Panel

Read article
Nova Log Viewer Package image

Nova Log Viewer Package

Read article

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

Pushsilver

Pushsilver is simple invoicing for freelancers and small studios — send polished invoices, automate reminders, and get paid on time without the bloat.

Pushsilver

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

Let your users buy domains without leaving your app

If your Laravel app gives users a site, a storefront, or a workspace, they’ll eventually want their own domain. The name.com API lets them search, register, and connect one without leaving your product. It’s a clean REST API, so Laravel’s HTTP client is all you need.

Let your users buy domains without leaving your app

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing