Send Logs over HTTP
Use
provideLumberjackHttpDriver
with withHttpConfig
or withHttpOptions
to POST logs to an endpoint that accepts the driver’s payload.
Before you start
Section titled “Before you start”provideLumberjack()already in the app providers.- An HTTP endpoint that accepts POST (the driver does not fall back to other verbs).
-
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'], }) ), ], });provideLumberjackHttpDriveralso registersprovideHttpClient(pass extraHttpClientfeatures as further arguments if needed). -
Choose config vs options
Helper Use when withHttpConfig(config)Full driver config: origin,storeUrl,retryOptions, andlevelsare required;identifieris optional.withHttpOptions(options)HTTP fields only ( origin,storeUrl,retryOptions);levelsandidentifierfall back to the root defaults.
Required HTTP settings
Section titled “Required HTTP settings”| Field | Purpose |
|---|---|
origin | Application id sent with each log for store-side grouping |
storeUrl | POST URL of the log store |
retryOptions.maxRetries | Attempts before the request fails |
retryOptions.delayMs | Delay between retries |
With withHttpOptions, levels and identifier are optional (identifier
defaults to LumberjackHttpDriver).
Verify
Section titled “Verify”Trigger a critical or error log and confirm a POST to storeUrl. With the
example levels, info/debug logs only hit the console driver.