An out the box activity logger for your Laravel or Lumen application. Laravel logger is an activity event logger for your laravel application. It comes out the box with ready to use with dashboard to view your activity. Laravel logger can be added as a middleware or called through a trait. This package is easily configurable and customizable. Supports Laravel 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, and 7+
Laravel logger is an activity event logger for your Laravel or Lumen application. It comes out the box with ready to use with dashboard to view your activity. Laravel logger can be added as a middleware or called through a trait. Easily have an Activity Log. This package is easily configurable and customizable. Supports Laravel 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, 7, 8 and 9+
Laravel Activity Logger Features |
---|
Logs login page visits |
Logs user logins |
Logs user logouts |
Routing Events can recording using middleware |
Records activity timestamps |
Records activity description |
Records activity details (optional) |
Records model related to the activity (optional) |
Records activity user type with crawler detection |
Records activity Method |
Records activity Route |
Records activity Ip Address |
Records activity User Agent |
Records activity Browser Language |
Records activity referrer |
Customizable activity model |
Activity panel dashboard |
Individual activity drilldown report dashboard |
Activity Drilldown looks up Id Address meta information |
Activity Drilldown shows user roles if enabled |
Activity Drilldown shows associated user events |
Activity log can be cleared, restored, and destroyed using eloquent softdeletes |
Cleared activity logs can be viewed and have drilldown ability |
Uses font awesome, cdn assets can be optionally called in configuration |
Uses Geoplugin API for drilldown IP meta information |
Uses Language localization files |
Lots of configuration options |
If youβd prefer a more visual review of this package, please watch this video on Laravel Package Tutorial.
Laravel logger can work out the box with or without the following roles packages:
composer require jeremykenedy/laravel-logger
Laravel 5.5 and up
Uses package auto discovery feature, no need to edit the config/app.php
file.
Laravel 5.4 and below
Register the package with laravel in config/app.php
under providers
with the following:
'providers' => [
jeremykenedy\LaravelLogger\LaravelLoggerServiceProvider::class,
];
php artisan migrate
.env
file with the needed configuration variables.Optionally Update your .env
file and associated settings (see Environment File section)
Optionally publish the packages views, config file, assets, and language files by running the following from your projects root folder:
php artisan vendor:publish --tag=LaravelLogger
composer require jeremykenedy/laravel-logger
Register the package with laravel in bootstrap/app.php
with the following:
$app->register(\Jaybizzle\LaravelCrawlerDetect\LaravelCrawlerDetectServiceProvider::class);
$app->configure('laravel-logger');
$app->register(\jeremykenedy\LaravelLogger\LaravelLoggerServiceProvider::class);
$app->routeMiddleware(['activity' => \jeremykenedy\LaravelLogger\App\Http\Middleware\LogActivity::class, ]);
config/
directory php artisan migrate
.env
file with the needed configuration variables..env
file and associated settings (see Environment File section)Laravel Activity Logger can be configured in directly in /config/laravel-logger.php
if you published the assets.
Or you can variables to your .env
file.
Here are the .env
file variables available:
LARAVEL_LOGGER_DATABASE_CONNECTION=mysql
LARAVEL_LOGGER_DATABASE_TABLE=laravel_logger_activity
LARAVEL_LOGGER_ROLES_ENABLED=true
LARAVEL_LOGGER_ROLES_MIDDLWARE=role:admin
LARAVEL_LOGGER_MIDDLEWARE_ENABLED=true
LARAVEL_LOGGER_MIDDLEWARE_EXCEPT=
LARAVEL_LOGGER_ACTIVITY_MODEL=jeremykenedy\LaravelLogger\App\Models\Activity
LARAVEL_LOGGER_USER_MODEL=App\User
LARAVEL_LOGGER_USER_ID_FIELD=id
LARAVEL_LOGGER_DISABLE_ROUTES=false
LARAVEL_LOGGER_PAGINATION_ENABLED=true
LARAVEL_LOGGER_CURSOR_PAGINATION_ENABLED=false
LARAVEL_LOGGER_PAGINATION_PER_PAGE=25
LARAVEL_LOGGER_DATATABLES_ENABLED=true
LARAVEL_LOGGER_ENABLE_SEARCH=true
LARAVEL_LOGGER_SEARCH_FIELDS=description,user,method,route,ip
LARAVEL_LOGGER_DASHBOARD_MENU_ENABLED=true
LARAVEL_LOGGER_DASHBOARD_DRILLABLE=true
LARAVEL_LOGGER_LOG_RECORD_FAILURES_TO_FILE=true
LARAVEL_LOGGER_FLASH_MESSAGE_BLADE_ENABLED=true
LARAVEL_LOGGER_LAYOUT=layouts.app
LARAVEL_LOGGER_BOOTSTRAP_VERSION=4
LARAVEL_LOGGER_BLADE_PLACEMENT=stack #option: yield or stack
LARAVEL_LOGGER_BLADE_PLACEMENT_CSS=css-header #placement name
LARAVEL_LOGGER_BLADE_PLACEMENT_JS=scripts-footer #placement name
LARAVEL_LOGGER_JQUERY_CDN_ENABLED=true
LARAVEL_LOGGER_JQUERY_CDN_URL=https://code.jquery.com/jquery-2.2.4.min.js
LARAVEL_LOGGER_BOOTSTRAP_CSS_CDN_ENABLED=true
LARAVEL_LOGGER_BOOTSTRAP_CSS_CDN_URL=https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css
LARAVEL_LOGGER_BOOTSTRAP_JS_CDN_ENABLED=true
LARAVEL_LOGGER_BOOTSTRAP_JS_CDN_URL=https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js
LARAVEL_LOGGER_POPPER_JS_CDN_ENABLED=true
LARAVEL_LOGGER_POPPER_JS_CDN_URL=https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js
LARAVEL_LOGGER_FONT_AWESOME_CDN_ENABLED=true
LARAVEL_LOGGER_FONT_AWESOME_CDN_URL=https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css
Events for laravel authentication scaffolding are listened for as providers and are enabled via middleware.
You can add events to your routes and controllers via the middleware:
activity
Example to start recording page views using middlware in web.php
:
Route::group(['middleware' => ['web', 'activity']], function () {
Route::get('/', 'WelcomeController@welcome')->name('welcome');
});
This middlware can be enabled/disabled in the configuration settings.
Events can be recorded directly by using the trait.
When using the trait you can customize the event description.
To use the trait:
Include the call in the head of your class file:
use jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger;
Include the trait call in the opening of your class:
use ActivityLogger;
You can record the activity by calling the traits method:
ActivityLogger::activity("Logging this activity.");
Or as bellow to include extended activity details:
ActivityLogger::activity("Logging this activity.", "Additional activity details.");
Or even including the model related to the activity:
ActivityLogger::activity("Logging this activity.", "Additional activity details.", ["id" => 1, "model" => "App\Models\User"]);
/activity
/activity/cleared
/activity/log/{id}
/activity/cleared/log/{id}
If you wish to change the route paths, names or other options you can disable the default routes in your .env
file by setting
LARAVEL_LOGGER_DISABLE_ROUTES=true
If you are on an existing install, you will also need update your laravel-logger.php
config file to add the config option:
'disableRoutes' => env('LARAVEL_LOGGER_DISABLE_ROUTES', false),
You can then add the routes directly to your applicationβs routes/web.php
file, and customise as required.
Route::group(['prefix' => 'activity', 'namespace' => 'jeremykenedy\LaravelLogger\App\Http\Controllers', 'middleware' => ['web', 'auth', 'activity']], function () {
// Dashboards
Route::get('/', 'LaravelLoggerController@showAccessLog')->name('activity');
Route::get('/cleared', ['uses' => 'LaravelLoggerController@showClearedActivityLog'])->name('cleared');
// Drill Downs
Route::get('/log/{id}', 'LaravelLoggerController@showAccessLogEntry');
Route::get('/cleared/log/{id}', 'LaravelLoggerController@showClearedAccessLogEntry');
// Forms
Route::delete('/clear-activity', ['uses' => 'LaravelLoggerController@clearActivityLog'])->name('clear-activity');
Route::delete('/destroy-activity', ['uses' => 'LaravelLoggerController@destroyActivityLog'])->name('destroy-activity');
Route::post('/restore-log', ['uses' => 'LaravelLoggerController@restoreClearedActivityLog'])->name('restore-activity');
});
adding dynamic search fields (description , user, URL , method and ip address)
When dealing with millions activity records, default behavior of not paginate records or Laravelβs paginator (enabled LARAVEL_LOGGER_PAGINATION_ENABLED=true
) may lead to huge performance penalties. For that use case you may set LARAVEL_LOGGER_CURSOR_PAGINATION_ENABLED=true
to enable Laravelβs Cursor Pagination feature. This will heavily improve Laravel Logger page loading time. If you choose to do so itβs advisable to read Cursor vs. Offset Pagination section on Laravelβs documentation to get acquainted with Cursor Pagination limitations.
add these configurations to your .env file to control the logging search
LARAVEL_LOGGER_ENABLE_SEARCH=true
// you can customize your search using these options [description,user,method,route,ip]
LARAVEL_LOGGER_SEARCH_FIELDS=description,user,method,route,ip
by default all search fields are enabled when you enable the search with this one line configuration
LARAVEL_LOGGER_SEARCH_ENABLE=true
βββ .env.travis
βββ .gitignore
βββ .travis.yml
βββ CODE_OF_CONDUCT.md
βββ LICENSE
βββ README.md
βββ composer.json
βββ src
βββ .env.example
βββ LaravelLoggerServiceProvider.php
βββ app
βΒ Β βββ Http
βΒ Β βΒ Β βββ Controllers
βΒ Β βΒ Β βΒ Β βββ LaravelLoggerController.php
βΒ Β βΒ Β βββ Middleware
βΒ Β βΒ Β βΒ Β βββ LogActivity.php
βΒ Β βΒ Β βββ Traits
βΒ Β βΒ Β βββ ActivityLogger.php
βΒ Β βΒ Β βββ IpAddressDetails.php
βΒ Β βΒ Β βββ UserAgentDetails.php
βΒ Β βββ Listeners
βΒ Β βΒ Β βββ LogAuthenticated.php
βΒ Β βΒ Β βββ LogAuthenticationAttempt.php
βΒ Β βΒ Β βββ LogFailedLogin.php
βΒ Β βΒ Β βββ LogLockout.php
βΒ Β βΒ Β βββ LogPasswordReset.php
βΒ Β βΒ Β βββ LogSuccessfulLogin.php
βΒ Β βΒ Β βββ LogSuccessfulLogout.php
βΒ Β βββ Logic
βΒ Β βΒ Β βββ helpers.php
βΒ Β βββ Models
βΒ Β βββ Activity.php
βββ config
βΒ Β βββ laravel-logger.php
βββ database
βΒ Β βββ migrations
βΒ Β βββ 2017_11_04_103444_create_laravel_logger_activity_table.php
βββ resources
βΒ Β βββ lang
βΒ Β βΒ Β βββ de
βΒ Β βΒ Β βΒ Β βββ laravel-logger.php
βΒ Β βΒ Β βββ en
βΒ Β βΒ Β βββ laravel-logger.php
βΒ Β βββ views
βΒ Β βββ forms
βΒ Β βΒ Β βββ clear-activity-log.blade.php
βΒ Β βΒ Β βββ delete-activity-log.blade.php
βΒ Β βΒ Β βββ restore-activity-log.blade.php
βΒ Β βββ logger
βΒ Β βΒ Β βββ activity-log-cleared.blade.php
βΒ Β βΒ Β βββ activity-log-item.blade.php
βΒ Β βΒ Β βββ activity-log.blade.php
βΒ Β βΒ Β βββ partials
βΒ Β βΒ Β βββ activity-table.blade.php
βΒ Β βββ modals
βΒ Β βΒ Β βββ confirm-modal.blade.php
βΒ Β βββ partials
βΒ Β βΒ Β βββ form-search.blade.php
βΒ Β βΒ Β βββ form-status.blade.php
βΒ Β βΒ Β βββ scripts.blade.php
βΒ Β βΒ Β βββ styles.blade.php
βΒ Β βββ scripts
βΒ Β βββ add-title-attribute.blade.php
βΒ Β βββ clickable-row.blade.php
βΒ Β βββ confirm-modal.blade.php
βΒ Β βββ datatables.blade.php
βΒ Β βββ tooltip.blade.php
βββ routes
βββ web.php
brew install tree
tree -a -I '.git|node_modules|vendor|storage|tests'
Before opening an issue there are a couple of considerations:
Laravel-logger is licensed under the MIT license. Enjoy!