- How do I install spatie/laravel-log-dumper in a Laravel project?
- Run `composer require spatie/laravel-log-dumper` in your project directory. No additional configuration is needed for basic usage—just call `ld()` anywhere in your code.
- Can I use `ld()` in production without risking log bloat?
- Yes, but disable it explicitly via `ld()->disable()` or wrap calls in environment checks like `if (app()->environment('local'))`. Avoid dumping large objects or sensitive data in production.
- What Laravel versions does this package support?
- The package is officially tested on Laravel 9+. For older versions (e.g., Laravel 8), check the [GitHub releases](https://github.com/spatie/laravel-log-dumper/releases) for compatibility notes.
- How does `ld()` handle complex objects like Closures or database models?
- It uses Symfony VarDumper for serialization, which works well for most objects. However, Closures or resources may not serialize predictably—test with your domain-specific data. For models, use `->toArray()` first if needed.
- Can I log to a specific Monolog channel (e.g., 'debug' or 'audit')?
- Yes, extend the package’s `LogDumper` service provider to add channel support. Example: `ld($data, channel: 'audit')`. Review the [README](https://github.com/spatie/laravel-log-dumper) for customization details.
- Is there a performance impact when using `ld()` in high-traffic APIs?
- Minimal during development. For production, disable logging entirely or use async logging (e.g., Monolog’s `AsyncHandler`) to avoid I/O bottlenecks. Test with your expected request volume.
- How do I chain multiple log levels (e.g., debug + error) in one call?
- Use method chaining: `ld()->debug('Debug data')->error('Error data')`. Each method call logs its arguments at the specified level, maintaining execution flow.
- What’s the difference between `ld()` and `Log::debug()`?
- `ld()` accepts multiple arguments and formats them with VarDumper for readability, while `Log::debug()` requires a single serialized array. `ld()` is ideal for quick debugging without manual array conversion.
- Can I temporarily disable `ld()` for specific code paths?
- Yes, call `ld()->disable()` before the block and `ld()->enable()` afterward. Example: `ld()->disable(); $riskyOperation(); ld()->enable();`
- Does this package work with Laravel’s log rotation or external tools like ELK?
- Yes, it integrates with Laravel’s default Monolog setup. For ELK or structured logging, ensure your Monolog handlers (e.g., `ElasticsearchHandler`) support the output format. Pair with `ld($data, channel: 'structured')` if needed.