- How do I install and set up colbeh/logs in a Laravel project?
- Run `composer require colbeh/logs` to install the package. Configure a custom logging channel in `config/logging.php` to route logs to the package, then bind the logger in your `AppServiceProvider` using Laravel’s service container. Ensure your `storage/logs/` directory is writable.
- Does colbeh/logs support Laravel 10?
- The package is designed for Laravel 8/9 and should work with Laravel 10 if no breaking changes affect the logging stack. Check the `composer.json` for PHP 8.0+ compatibility and verify with your Laravel version’s BC checks. Test thoroughly in a staging environment.
- Can I use colbeh/logs for production monitoring?
- While the package simplifies log viewing, it’s best suited for development or low-to-medium traffic environments. For production, consider pairing it with tools like Laravel Horizon or a dedicated log aggregation system (e.g., ELK stack) to handle volume and retention. Local storage may not scale beyond ~10K requests/day.
- How do I restrict access to the logs UI?
- The package doesn’t include built-in auth, but you can protect the log viewer by adding middleware like `auth:sanctum` or `can:view-logs` to the route handling log requests. Ensure sensitive data isn’t logged by using Laravel’s `Log::only()` or masking PII before writing logs.
- What if I need log archival or analysis?
- colbeh/logs stores logs locally and lacks built-in archival or analysis features. For advanced use cases, integrate with third-party tools like Elasticsearch, Loki, or Fluentd. Alternatively, use Laravel’s `Log::getMonolog()->read()` to export logs programmatically for analysis.
- Will this package slow down my Laravel app?
- The overhead is minimal for local storage, but high log volumes (e.g., thousands of entries per second) may impact performance. Monitor disk I/O and consider throttling logs in production. For high-traffic apps, offload logs to a dedicated service like Sentry or Datadog.
- How do I structure logs for better debugging?
- Use Laravel’s logging channels (e.g., `single`, `daily`) to separate log types (e.g., errors, debug). The package supports structured output, so include context like user IDs or request IDs in log messages. Example: `Log::channel('debug')->info('Event triggered', ['user_id' => 123]).
- Are there alternatives to colbeh/logs for Laravel?
- For log viewing, consider **Spatie’s Laravel Log Viewer** (simpler UI) or **Laravel Debugbar** (real-time debugging). For production monitoring, tools like **Sentry**, **Laravel Horizon**, or **Tymon’s JWT Auth + custom log routes** may fit better. Evaluate based on your need for UI access vs. scalability.
- How do I test if colbeh/logs is working correctly?
- Write unit tests to verify log entries are captured and retrievable. Use Laravel’s `Log::shouldReceive('info')->andReturnTrue()` in PHPUnit to mock logs, then assert the package’s storage or UI reflects the expected output. Test edge cases like log rotation and channel switching.
- Can I customize the log storage location or format?
- The package relies on Laravel’s filesystem, so you can configure storage paths in `config/filesystems.php`. For custom formats, extend the package’s logger class or override Monolog handlers in `config/logging.php`. Note: Database or S3 storage may require manual adapter setup.