- Can I use AbcLoggerBundle directly in a Laravel project, or is it Symfony-only?
- AbcLoggerBundle is designed for Symfony, but you can adapt its core logic for Laravel. Use spatie/laravel-monolog for Monolog integration and replicate the REST endpoint with Laravel’s routing (e.g., `routes/api.php`). Replace FOSRestBundle with native Laravel tools like fruitcake/laravel-cors for CORS support.
- How do I configure allowed applications and map them to Monolog channels in Laravel?
- In Laravel, define allowed apps and channels in `config/logging.php` under a custom key (e.g., `abc_logger`). Use middleware to validate the `X-App-Name` header before routing logs to the correct Monolog channel. Example: `Logger::channel('my_channel')->info($message, $context);`.
- What Laravel versions does AbcLoggerBundle support, or do I need a custom solution?
- AbcLoggerBundle doesn’t natively support Laravel, but its Monolog-based logic works across versions (5.8+). For a drop-in solution, consider forking the bundle or using a Laravel wrapper like `spatie/laravel-monolog` with custom API routes. Test compatibility with your Laravel version’s Monolog handler.
- How do I secure the `/api/log/{app}` endpoint in Laravel to prevent unauthorized log submissions?
- Add authentication via middleware (e.g., `laravel-sanctum` for tokens or `fruitcake/laravel-cors` with IP whitelisting). Validate the `X-App-Name` header against your `config/abc_logger.applications` list. For high-security needs, use mutual TLS or API keys passed in the request body.
- Does AbcLoggerBundle support structured logging with context data, like JSON payloads?
- Yes, the bundle accepts optional `context` as an array in the request body, which Monolog processes as structured metadata. In Laravel, ensure your Monolog handlers (e.g., `stream`, `syslog`) are configured to format context data (e.g., JSON via `monolog/handler-json`).
- What are the performance implications of high-volume logging with this bundle in production?
- The bundle processes logs synchronously, which may block HTTP requests under high load. For Laravel, offload logging to a queue using `laravel-queue` + `monolog/handler-async`. Alternatively, stream logs directly to a message broker (e.g., Kafka) or use a dedicated logging service like Papertrail.
- How can I integrate AbcLoggerBundle with Laravel’s API documentation tools like Swagger?
- Replace Symfony’s NelmioApiDocBundle with Laravel alternatives like `darkaonline/l5-swagger` or `spatie/laravel-api-documentation`. Document the `/api/log/{app}` endpoint with `@POST` annotations, specifying required fields (`level`, `message`) and optional `context`. Example: `@bodyParam name="context" type="object" description="Additional log metadata"`.
- Are there alternatives to AbcLoggerBundle for Laravel that offer similar REST-based logging?
- For Laravel, consider `spatie/laravel-logging` (for structured logs) + custom API routes, or `monolog/monolog` with a dedicated controller. Symfony bundles like `stof/doctrine-extensions` (for ORM logs) or `sensio/framework-extra-bundle` (for request logging) aren’t direct replacements but may inspire custom solutions.
- How do I test the AbcLoggerBundle REST endpoint in Laravel during development?
- Use PHPUnit with `Http::post('/api/log/my_app', ['level' => 'info', 'message' => 'Test'])` to simulate log submissions. Mock Monolog handlers to verify channel routing. For integration tests, use Laravel’s `RefreshDatabase` trait if logs are stored in a database (e.g., with `monolog/handler-database`).
- What happens if the Monolog channel for an application isn’t configured in AbcLoggerBundle?
- The bundle will reject the log request with a `400 Bad Request` if the `X-App-Name` header doesn’t match a configured application. In Laravel, handle this in middleware by throwing a `HttpException` or logging a warning to a fallback channel (e.g., `null` or `default`).