Skip to content

Audit Log

Doggy provides full-chain operation auditing via AuditService, recording all critical operations in App\Entity\System\AuditLog.

Overview

The audit system consists of:

  • AuditLog entity (src/Entity/System/AuditLog.php): Persists audit records
  • AuditService (src/Service/System/AuditService.php): Logging service
  • Admin entry: App\Controller\Admin\SecurityConfigController

Recorded Content

Each audit log contains:

  • action: Operation type (login_success, login_failure, create, update, delete)
  • category: Category (security, business, system)
  • details: Operation details (JSON)
  • performer: User who performed the action

Usage

php
use App\Service\System\AuditService;

class SomeService
{
    public function __construct(private AuditService $auditService) {}

    public function doSomething(): void
    {
        // Login success
        $this->auditService->log('login_success', 'security', [], $user);

        // Login failure
        $this->auditService->log('login_failure', 'security', [
            'username' => $email,
            'error' => $exception->getMessage(),
        ]);

        // Data operation
        $this->auditService->log('update', 'business', [
            'entity' => Employee::class,
            'id' => $employee->getId(),
            'changes' => $changes,
        ]);
    }
}

Integration

Audit logging is automatically integrated into the main security flows:

Authentication

App\Security\AppCustomAuthenticator automatically records:

php
// On login success
$this->auditService->log('login_success', 'security', [], $user);

// On login failure
$this->auditService->log('login_failure', 'security', [
    'username' => $email,
    'error' => $exception->getMessage(),
]);

Security Requirements

  • Audit logs are viewable only by auditors (ROLE_AUDITOR, via ThreeOfficersVoter.AUDIT_VIEW)
  • Logs are stored in the database for traceability and export
  • Supports search by time range, user, and operation type

Open Source under MIT | Copyright © 2026 Doggy