syonix / monolog-viewer
An easy-to-use viewer for log files generated by Monolog (https://github.com/Seldaek/monolog)
Installs: 6 057
Dependents: 0
Suggesters: 0
Security: 0
Stars: 273
Watchers: 11
Forks: 67
Open Issues: 32
Language:CSS
Type:project
Requires
- php: >=5.4
- ddtraceweb/monolog-parser: 1.*
- deralex/yaml-config-service-provider: ~1.0
- doctrine/collections: ~1.3
- ircmaxell/password-compat: 1.*
- league/flysystem: ~1.0
- league/flysystem-cached-adapter: ~1.0
- phpunit/phpunit: ~4.7
- rmccue/requests: 1.6.*
- silex/silex: ~1.2
- symfony/security: ~2.3
- symfony/twig-bridge: 2.7.*
- twig/twig: >=1.8,<2.0-dev
README
A viewer to nicely display log files generated by Monolog.
Installation & Setup
- Download Composer
- Execute
php composer.phar create-project syonix/monolog-viewer install-directory/
(make sure to replaceinstall-directory
with the name of the directory you want to install monolg viewer into. - Upload the files to your webspace
- 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. - Create a configuration file (rename or copy the
config_example.yaml
). - Open Monolog Viewer in the browser
- Enter a password of your choice twice and click "Create login".
- 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:
Flysystem Types
local
Accesses log files on the server's local file system.
ftp
Accesses log files via FTP.
sftp
Accesses log files via SFTP.
All types
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]