Kotchasan Framework Documentation

Kotchasan Framework Documentation

Kotchasan\Logger\SystemLogger

EN 05 Feb 2026 07:40

Kotchasan\Logger\SystemLogger

SystemLogger writes logs to system log (syslog).

Usage

use Kotchasan\Logger\SystemLogger;

$logger = new SystemLogger('myapp');

$logger->info('Application started');
$logger->error('Critical error occurred');

Constructor

public function __construct(string $ident = 'kotchasan')

Parameters:

  • $ident - Identifier name for syslog

When to Use

  • Production servers
  • When centralized logging is needed
  • Integration with log management systems
  • Security and audit logging

Example

Production Logging

use Kotchasan\Logger\SystemLogger;

$logger = new SystemLogger('mywebapp');

// Log security events
$logger->warning('Failed login attempt', [
    'ip' => $_SERVER['REMOTE_ADDR'],
    'username' => $username
]);

// Critical errors
$logger->critical('Database connection lost');

View Logs

# Linux
tail -f /var/log/syslog | grep myapp

# macOS
log show --predicate 'process == "myapp"' --last 1h