Level 39
Why don't you close (Best answer) of your previous post?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to save spatie activity logs in separate database .
database name = "lms_logs"
But it doesn't work. please help me some one to resolve this
config> activitylog.php
..
'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'),
..
Env
ACTIVITY_LOGGER_ENABLED=true
ACTIVITY_LOGGER_DB_CONNECTION=mysql
ACTIVITY_LOGGER_DB_HOST=127.0.0.1
ACTIVITY_LOGGER_DB_PORT=3308
ACTIVITY_LOGGER_DB_DATABASE=lms_logs
ACTIVITY_LOGGER_DB_USERNAME=root
ACTIVITY_LOGGER_DB_PASSWORD=
Run DB Migration
php artisan migrate:fresh
Clear Config Cache
php artisan config:clear
activitylog.php
...
/*
* This is the database connection that will be used by the migration and
* the Activity model shipped with this package. In case it's not set
* Laravel database.default will be used instead.
*/
'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'),
...
database.php
'mysql2' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('ACTIVITY_LOGGER_DB_DATABASE', 'lms_logs'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => 'innodb',
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
env
ACTIVITY_LOGGER_DB_CONNECTION=mysql2
ACTIVITY_LOGGER_DATABASE=lms
actvity_log_migration_table.php
....
public function up()
{
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('log_name')->nullable();
$table->text('description');
$table->nullableMorphs('subject', 'subject');
$table->nullableMorphs('causer', 'causer');
$table->json('properties')->nullable();
$table->timestamps();
$table->index('log_name');
});
}
....
Please or to participate in this conversation.