Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Yii2 Psr Log Target

Yii2 Psr Log Target Laravel Package

samdark/yii2-psr-log-target

Yii2 log target that forwards Yii log messages to any PSR-3 logger (e.g., Monolog). Configure PsrTarget in the log component, choose levels, and optionally add real event timestamps to the log context for accurate timing.

View on GitHub
Deep Wiki
Context7

samdark/yii2-psr-log-target adds a Yii2 log target that forwards framework log messages to any PSR-3 compatible logger (e.g., Monolog), letting you reuse existing handlers and transports like Slack, files, syslog, or cloud logging.

Configure samdark\log\PsrTarget in the Yii log component, provide a PSR-3 logger, and optionally tune which levels are sent and how timestamps are handled.

  • Routes Yii2 logs to any PSR-3 logger implementation
  • Simple Yii log component integration via PsrTarget
  • Flexible level mapping/filtering (strings, Yii levels, PSR levels)
  • Optional real timestamps via addTimestampToContext for buffered logs
  • Works seamlessly with Monolog handlers and ecosystems
Frequently asked questions about Yii2 Psr Log Target
Can I use this package in a Laravel project to log Yii2 framework logs?
No, this package is specifically for Yii2 and won’t work directly in Laravel. However, you can use it in Yii2 components (e.g., APIs or queues) to forward logs to a shared PSR-3-compatible sink like Syslog or a message queue, then ingest those logs in Laravel via a custom driver.
How do I configure this package to send Yii2 logs to Monolog in Laravel?
This package isn’t designed for Laravel, but you could configure Yii2 to log to a shared transport (e.g., Redis or a database table) via this package, then create a Laravel LogServiceProvider channel to read from that transport. Alternatively, use a message queue like RabbitMQ to aggregate logs centrally.
What Laravel versions or logging systems does this package integrate with?
This package doesn’t integrate with Laravel directly. However, since Laravel uses PSR-3 (Monolog) under the hood, you could configure this package in Yii2 to forward logs to a PSR-3 logger, then route those logs to Laravel’s Monolog via a shared handler or transport.
How do I filter which Yii2 log levels are sent to the PSR-3 logger?
Use the `levels` configuration option in the `PsrTarget` to specify which Yii2 log levels (e.g., `info`, `warning`) or PSR-3 levels (e.g., `CRITICAL`) should be forwarded. You can pass an array of strings or constants for granular control.
Will this package work with Laravel’s built-in logging (Log::channel) for hybrid Yii2/Laravel apps?
Not natively, but you can create a hybrid setup where Yii2 logs are forwarded to a shared PSR-3 logger (e.g., Monolog) via this package, and Laravel’s `Log::channel` consumes the same logger. This requires configuring both frameworks to use the same PSR-3 logger instance.
Does this package support structured logging or JSON formatting for cloud tools like Datadog?
Yes, since it forwards logs to any PSR-3 logger, you can configure Monolog with handlers like `StreamHandler` (for JSON files) or cloud-specific handlers (e.g., Datadog’s `DatadogHandler`) to enable structured logging. Ensure your PSR-3 logger is set up for the desired format.
How do I handle timestamps in buffered Yii2 logs when using this package?
Enable the `addTimestampToContext` option in `PsrTarget` to include real event timestamps in the log context, even if Yii2’s buffering delays log writes. This ensures accurate timing in your PSR-3 logger’s output.
What happens if the PSR-3 logger fails (e.g., network error to Slack)?
This package doesn’t include built-in fallback mechanisms. If the PSR-3 logger fails, logs may be silently dropped. To mitigate this, configure Yii2’s native logger to also write to a fallback target (e.g., file) while using this package for secondary logging.
Can I use this package to migrate from Yii2’s native logger to Laravel’s Monolog?
Yes, this package acts as a bridge during migration. Configure Yii2 to log to both its native targets and this PSR-3 target (e.g., Monolog). Gradually replace Yii2’s logger with the PSR-3 logger in your codebase, then remove this package once fully migrated to Laravel.
Are there performance implications for high-traffic Yii2 applications using this package?
Potential overhead exists due to PSR-3 serialization and handler processing, especially if logs are reformatted or sent to remote systems. Test under load to ensure your PSR-3 logger (e.g., Monolog with async handlers) can handle your traffic without bottlenecks.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport