yiisoft/log-target-file
File log target for Yii's logging library that writes application messages to configurable log files. Supports level and category filtering, custom formatting, size-based rotation, and retention of rotated files—a straightforward choice for persistent file-based logging in Yii apps.
What it is: yiisoft/log-target-file is the file-writing target (handler) for Yii's yiisoft/log logging library. It receives PSR-3-style log records from the Yii logger and persists them to disk, including rotation behavior. It is a leaf component in the Yii 3 dependency-injection and configuration ecosystem, not a standalone logging framework.
Architecture fit: Low for a Laravel codebase. Laravel's logging is Monolog-centric and exposes a channel/handler/formatter/processor/tap model through config/logging.php and the Log facade. This package has no Laravel service provider, no channel driver, no config bridge, and no awareness of Laravel's contextual logging, exception rendering, or Monolog\Handler\HandlerInterface. Adopting it means either (a) running a second, parallel logging stack beside Monolog, or (b) writing an adapter that translates Monolog records into Yii log records — at which point the package's value proposition is almost entirely eroded.
Integration feasibility: Technically possible because the underlying logger is PSR-3 compatible, so a Psr\Log\LoggerInterface can be constructed and injected. Practically, this is a "can" not a "should." The effort is not in wiring a single class; it is in reproducing rotation, formatting, context enrichment, and error handling that Laravel already provides out of the box via single, daily, stderr, and custom Monolog handlers.
Technical risk:
yiisoft/log and its transitive Yii dependencies, plus a DI/config convention (yiisoft/config, definitions) foreign to Laravel's container.StreamHandler/RotatingFileHandler. Any divergence in log-loss behavior is a production incident vector, and log pipelines are rarely covered by functional tests.LineFormatter, exception normalization, and context/extra merging are tuned for Laravel's data shapes. Yii's formatter expectations differ; parity requires custom work.Key questions:
Stack fit: Poor as a primary logger, acceptable as a scoped component. Laravel's Log facade, channel configuration, and report() exception path should remain untouched. The only defensible placement is a separate, explicitly constructed logger instance used by a bounded subsystem (e.g., a ported Yii module or a batch job), writing to its own file namespace and excluded from the main observability contract.
Migration path: There is no migration path to this package, and there should not be one. Treat it as a point solution: identify the specific requirement, prove the package meets it, and scope the integration to the smallest possible surface. If the requirement is rotation or retention, first verify Monolog cannot satisfy it — in most cases a small custom Monolog\Handler wrapping RotatingFileHandler is cheaper and safer than importing a second logging stack.
Compatibility: Confirm the PHP constraint against the platform matrix, verify the psr/log version resolves against Laravel's (Laravel pins a Monolog/PSR-3 combination), and run a full composer why-not audit before adding the dependency. Watch for Yii DI/config packages arriving transitively; strip them and instantiate the target directly to avoid pulling a container convention into a Laravel app.
Sequencing:
Monolog\Handler\HandlerInterface (or a Psr\Log\LoggerInterface binding) that delegates to the target, so call sites never reference Yii types and the dependency stays behind one seam.Maintenance: This is the dominant cost. The team inherits a dependency whose roadmap is set by the Yii project, not by Laravel's release cycle. Every Laravel upgrade that touches Monolog, PSR-3, or the container requires re-validating the adapter. Budget a recurring line item for dependency review and CVE monitoring; the low star count means community triage is thin, and security advisories will surface through the Yii ecosystem rather than the usual Laravel channels.
Support: Escalation paths are limited to the upstream repository and Yii community channels, neither of which aligns with the team's existing Laravel expertise or vendor relationships. There is no commercial support and no realistic prospect of hiring for it. Internal documentation of the adapter becomes the de facto support artifact — if it is not written, the integration is effectively unmaintainable.
Scaling: File-based logging scales with the filesystem, not the application. On ephemeral or containerized infrastructure, local files require a sidecar or volume mount, and rotation creates contention under high write concurrency. Confirm behavior under concurrent writers across multiple PHP-FPM workers and container replicas — this is the most likely place a Yii-tuned component diverges from a Monolog-tuned operations setup. Centralized log shipping (stdout/stderr collection) is the Laravel norm; this package pushes toward file-based collection, which is an architectural step backward for containerized deployments.
Failure modes:
composer update: breaks the build, blocking unrelated upgrades.Ramp-up: Non-trivial and asymmetric. The team already knows Monolog; nobody knows Yii's log target, its formatter contracts, or its DI conventions. Expect several days of ramp-up to reach basic competence and weeks before someone can confidently debug rotation or concurrency behavior in production. That cost is paid once for the integration and again at every handoff, and it is disproportionate to a component that duplicates an existing, well-understood capability.
Recommendation: Do not adopt for general application logging. Pursue only if the key-questions triage surfaces a specific capability gap that Monolog cannot close with a modest custom handler — in which case isolate it behind an adapter, shadow-test it through a full rotation cycle, and keep the rollback trivial.
How can I help you explore Laravel packages today?