Flow PHP

LoggerProvider

Read onlyYes
FinalYes

Entry point for the logging API.

Creates and manages loggers for different instrumentation scopes. The behavior (void, memory, OTLP, etc.) is determined by the injected processor.

Example usage:

// For testing with memory storage
$processor = new MemoryProcessor($exporter, $exporter, $exporter);
$provider = new LoggerProvider($processor, new SystemClock());

// For OTLP export
$processor = batching_log_processor(otlp_log_exporter($transport));
$provider = new LoggerProvider($processor, new SystemClock());

// For void/disabled logging
$provider = new LoggerProvider(new VoidProcessor(), new SystemClock());

$logger = $provider->logger('my-service', '1.0.0');
$logger->info('Application started');

Methods

__construct()  : mixed
logger()  : Logger
Create a logger for the given instrumentation scope.

Methods

logger()

Create a logger for the given instrumentation scope.

public logger(resource $resource, string $name[, string $version = 'unknown' ][, null|string $schemaUrl = null ][, null|Attributes $attributes = null ]) : Logger

Note: Instance caching is handled by the Telemetry class. This method always creates a new Logger instance.

Parameters
$resource : resource

The resource context for all logs from this logger

$name : string

The name of the instrumentation scope (e.g., library name)

$version : string = 'unknown'

The version of the instrumentation scope

$schemaUrl : null|string = null

Schema URL for semantic conventions

$attributes : null|Attributes = null

Additional scope attributes

Return values
Logger

        
On this page

Search results