Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Syslog Bundle Laravel Package

digipolisgent/syslog-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install the Bundle

    composer require digipolisgent/syslog-bundle
    
  2. Enable the Bundle Add to config/bundles.php:

    return [
        // ...
        Digipolis\SyslogBundle\DigipolisSyslogBundle::class => ['all' => true],
    ];
    
  3. Configure Syslog Identity Add to config/packages/devmonolog.yaml (or your Monolog config):

    digipolis_syslog_identity:
        name: "your_app_name"
        facility: "local0"  # Default: "local0"
        host: "localhost"   # Default: "localhost"
        port: 514           # Default: 514
    
  4. First Use Case: Logging to ELK Inject the logger in a service/controller:

    use Psr\Log\LoggerInterface;
    
    class SomeController
    {
        public function __construct(private LoggerInterface $logger)
        {
        }
    
        public function index()
        {
            $this->logger->info('Test message', ['context' => 'data']);
        }
    }
    

Implementation Patterns

Common Workflows

  1. Structured Logging for Kibana Use JSON-formatted logs with context arrays for easy filtering in Kibana:

    $this->logger->error('Failed to process order', [
        'order_id' => 123,
        'user_id' => 456,
        'error' => 'Payment declined'
    ]);
    
  2. Conditional Logging Leverage Monolog’s channel system to route logs differently:

    # config/packages/monolog.yaml
    monolog:
        handlers:
            syslog:
                type: syslog
                level: debug
                channels: ["app", "security"]
    
  3. Custom Formatter Overrides Extend the default formatter (if needed) by creating a custom handler:

    # config/packages/monolog.yaml
    monolog:
        handlers:
            custom_syslog:
                type: custom_handler
                formatter: Digipolis\SyslogBundle\Formatter\ElkFormatter
                level: info
    
  4. Environment-Specific Configs Use separate configs for dev/prod:

    # config/packages/prod/monolog.yaml
    digipolis_syslog_identity:
        facility: "local1"  # Different facility for production
        host: "syslog.prod.example.com"
    
  5. Integration with Laravel (Symfony Bridge) If using Laravel, bridge the bundle via symfony/monolog-bundle:

    // config/app.php
    'providers' => [
        // ...
        Symfony\Bridge\Monolog\MonologServiceProvider::class,
    ],
    

Gotchas and Tips

Pitfalls

  1. Deprecated Bundle

    • Last release in 2018; test thoroughly in your environment.
    • May not support PHP 8.x or newer Symfony/Laravel versions.
    • Mitigation: Fork the repo and update dependencies if needed.
  2. Syslog Facility Limits

    • Syslog facilities (local0-local7) are often restricted on shared hosts.
    • Tip: Use user or daemon if local* is blocked.
  3. Kibana Parsing Issues

    • Ensure the formatter’s JSON output matches your Kibana index pattern.
    • Debug: Log raw output to a file first:
      handlers:
          file:
              type: stream
              path: "%kernel.logs_dir%/%kernel.environment%.log"
              level: debug
      
  4. Port/Protocol Conflicts

    • Syslog over UDP (default) may drop logs under load.
    • Tip: Use TCP (port: 514, transport: "tcp" in config) for reliability.
  5. Context Depth Limits

    • Syslog has a 1024-byte limit for messages.
    • Tip: Truncate large contexts or use a separate log for critical data.

Debugging

  • Check Syslog Server Logs
    tail -f /var/log/syslog  # Linux
    journalctl -u rsyslog   # Systemd
    
  • Test Locally with logger Command
    logger -p local0.info "Test message"
    
  • Enable Monolog Debug Handler
    handlers:
        debug:
            type: stream
            path: "php://stderr"
            level: debug
    

Extension Points

  1. Custom Handlers Extend Digipolis\SyslogBundle\Handler\SyslogHandler to add pre-processing:

    class CustomSyslogHandler extends SyslogHandler
    {
        protected function write(array $record): void
        {
            $record['extra']['custom_field'] = 'value';
            parent::write($record);
        }
    }
    
  2. Dynamic Facility/Host Override config via dependency injection:

    $container->setParameter('digipolis_syslog_identity.facility', 'local1');
    
  3. Add Metadata Inject request/user data automatically:

    $handler = new SyslogHandler($level, $bubble, [
        'extra' => [
            'request_id' => $this->getRequestId(),
            'user_id' => $this->getUserId(),
        ],
    ]);
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment