caixingyue/laravel-star-log
Laravel Star Log is a lightweight Laravel package for structured application logging. It provides simple configuration and helpers to write, organize, and manage logs, making debugging and monitoring clearer in Laravel projects.
composer require caixingyue/laravel-star-log — v2.0.1 is a drop-in patch over 2.0.0, so any pinned ^2.0 constraint picks it up with a plain composer update. No migration, no config republish required.php artisan vendor:publish and select the Star Log provider/tag from the package README) and open config/star-log.php first. This single file is where every feature is switched on: HTTP client logging, query logging, connection-failure logging, exception logging, user-agent/device detection, and the per-feature channel/level settings. Nothing is logged until you enable a block and point it at a channel.config/logging.php. The package expects a dedicated channel (e.g. star-log) rather than the default stack, so add one early — you want these entries isolated from application logs from day one.Channel-per-concern, not one giant log. Give each feature its own channel (star-log-http, star-log-query, star-log-exceptions) using the daily driver. Query logs in particular explode in volume; separating them keeps your log shipper's parsing rules sane and lets you set different retention per stream.
HTTP client middleware, per named client. Register the logging middleware on the specific clients you care about rather than globally. Laravel's Http:: facade makes it easy to build a base client in a service provider and attach the middleware there, so every consumer of that client inherits consistent logging without remembering to opt in. Do this for outbound integrations; skip it for internal service calls that would flood the log.
Mask before you log, not after. Configure header and body redaction (Authorization, cookies, API keys, password fields) in the package config. Treat this as mandatory: these logs land on disk and in your aggregator, and HTTP request bodies routinely carry credentials.
Use the connection-failure log as your alerting signal. This is the entry type that survives when a request never got a response at all — DNS failure, timeout, refused connection. Route it to the channel your alerting watches, and keep it enabled in production even if you turn general HTTP logging down. v2.0.1 specifically hardens this path on Guzzle 8 and stops the failure-log middleware callbacks from running at all when both HTTP and connection-failure logging are disabled, so a "logging off" environment is now truly zero-cost.
Never clobber the statistics callback. If you supply your own Guzzle statistics callback for metrics, the package now merges transport statistics into it instead of overwriting it. Keep your callback pure and idempotent — read stats off the transfer, don't mutate shared state — and both your metrics and the package's failure reasons will coexist.
Slow-query thresholding for anything query-related. Set a millisecond threshold comfortably above your p95 and log only beyond it. Full query logging belongs in local/staging; production should be threshold-only plus sampling.
Enrich with request context. Push a request/trace ID, authenticated user ID, and route into the log context so an HTTP-client entry can be correlated with the inbound request that triggered it. Without this, outbound logs are orphans.
Device/user-agent detection is opt-in and dependency-backed. If Mobile Detect is installed, the package can annotate entries with device class. Useful for debugging mobile-specific issues on public endpoints; noise everywhere else — enable it per channel.
guzzlehttp/guzzle:^8.0, do not expect this package to be validated against it. Don't "helpfully" bump it in a Laravel 12 app.guzzlehttp/psr7 3.x, Guzzle 7 with 2.x. A stray direct constraint on guzzlehttp/psr7 in your composer.json is the most likely cause of a resolver conflict after upgrading; check that before filing anything.composer update --prefer-lowest in CI is worth adding here — the release explicitly covers lowest-supported dependency versions, and that's where PSR-7 signature mismatches surface.config/star-log.php; is the configured channel present in config/logging.php and writable; is the entry's level at or above the channel's threshold; is the middleware actually attached to the client you're using (named clients don't inherit unless you attach it). Ninety percent of "the package doesn't work" is the fourth item.logging.php let you ship these entries to a different sink (e.g. a separate index) without touching the package config beyond the channel name.^2.0.1 rather than ^2.0.0 so environments that resolved early don't sit on the old callback semantics.How can I help you explore Laravel packages today?