Skip to content

Send Logs over HTTP

Use provideLumberjackHttpDriver with withHttpConfig or withHttpOptions to POST logs to an endpoint that accepts the driver’s payload.

  • provideLumberjack() already in the app providers.
  • An HTTP endpoint that accepts POST (the driver does not fall back to other verbs).
  1. Register the HTTP driver

    import { bootstrapApplication } from '@angular/platform-browser';
    import { provideLumberjack } from '@ngworker/lumberjack';
    import { provideLumberjackConsoleDriver } from '@ngworker/lumberjack/console-driver';
    import { provideLumberjackHttpDriver, withHttpConfig } from '@ngworker/lumberjack/http-driver';
    
    import { AppComponent } from './app/app.component';
    
    bootstrapApplication(AppComponent, {
      providers: [
        provideLumberjack(),
        provideLumberjackConsoleDriver(),
        provideLumberjackHttpDriver(
          withHttpConfig({
            origin: 'ForestApp',
            storeUrl: '/api/logs',
            retryOptions: { maxRetries: 5, delayMs: 250 },
            levels: ['critical', 'error'],
          })
        ),
      ],
    });

    provideLumberjackHttpDriver also registers provideHttpClient (pass extra HttpClient features as further arguments if needed).

  2. Choose config vs options

    HelperUse when
    withHttpConfig(config)Full driver config: origin, storeUrl, retryOptions, and levels are required; identifier is optional.
    withHttpOptions(options)HTTP fields only (origin, storeUrl, retryOptions); levels and identifier fall back to the root defaults.
FieldPurpose
originApplication id sent with each log for store-side grouping
storeUrlPOST URL of the log store
retryOptions.maxRetriesAttempts before the request fails
retryOptions.delayMsDelay between retries

With withHttpOptions, levels and identifier are optional (identifier defaults to LumberjackHttpDriver).

Trigger a critical or error log and confirm a POST to storeUrl. With the example levels, info/debug logs only hit the console driver.