Core
Logger v1.x
2

Transport Configuration #

The Kuzzle Logger supports various transport configurations to determine how and where logs are written. You can use predefined presets or configure custom transports.

Transport Types #

1. Using Presets #

interface TransportPresetOptions {
  preset: 'stdout' | 'kuzzle-elasticsearch' | 'loki';
  level?: string;
  presetOptions?: PresetSpecificOptions;
}

See Presets for detailed preset configurations.

2. Multiple Transports #

interface TransportMultiOptionsWithPreset {
  targets: Array<
    TransportPresetOptions | pino.TransportTargetOptions | pino.TransportPipelineOptions
  >;
  levels?: Record<string, number>;
  dedupe?: boolean;
}

3. Single Transport #

interface TransportSingleOptions {
  target: string;
  options?: object;
  level?: string;
}

4. Pipeline Transport #

interface TransportPipelineOptions {
  pipeline: Array<{
    target: string;
    options?: object;
  }>;
}

Examples #

Using Stdout Preset #

const logger = new KuzzleLogger({
  transport: {
    preset: 'stdout',
  },
});

Using Multiple Transports #

const logger = new KuzzleLogger({
  transport: {
    targets: [
      {
        preset: 'stdout',
      },
      {
        preset: 'loki',
        presetOptions: {
          host: 'http://localhost:3100',
          labels: {
            app: 'my-app',
          },
        },
      },
    ],
  },
});

Custom Transport #

const logger = new KuzzleLogger({
  transport: {
    target: 'pino/file',
    options: {
      destination: '/var/log/app.log',
    },
  },
});

Pipeline Transport #

const logger = new KuzzleLogger({
  transport: {
    pipeline: [
      {
        target: 'pino-transport-ecs',
        options: {
          serviceName: 'my-service',
        },
      },
      {
        target: 'pino-elasticsearch',
        options: {
          node: 'http://localhost:9200',
          index: 'logs',
        },
      },
    ],
  },
});