Skip to content
Antares

Monolog Bridge

The Monolog bridge binds Psr\Log\LoggerInterface in the container using Monolog.

Terminal window
composer require fatjon-lleshi/antares-monolog-bridge

The bridge is auto-discovered — no manual registration needed.

Set these in your .env:

VariableDefaultDescription
LOG_CHANNELfilefile, stdout, or stderr
LOG_LEVELdebugAny PSR-3 level (debug, info, warning, error, …)
APP_NAMEantaresLogger channel name

When LOG_CHANNEL=file (or any value other than stdout / stderr), logs are written to storage/logs/app.log under the app’s base path, rotated daily and kept for 30 days.

The bridge registers Psr\Log\LoggerInterface and Monolog\Logger as singletons; both return the same logger.

Inject LoggerInterface anywhere in your application:

use Psr\Log\LoggerInterface;
class UserService
{
public function __construct(
private readonly LoggerInterface $logger,
) {}
public function create(CreateUserRequest $request): User
{
$user = User::create(['name' => $request->name, 'email' => $request->email]);
$this->logger->info('User created', ['id' => $user->id]);
return $user;
}
}