Skip to content

LoggerFactory

Default LoggerFactoryInterface: thin wrapper over the Log facade (and thus LogRegistry) for constructor injection via the DI container.

final class LoggerFactory implements LoggerFactoryInterface

ImplementsLoggerFactoryInterface
SourceLogging/LoggerFactory.php
MethodDescription
create(string $category): LoggerInterfaceReturns a logger bound to the given category name verbatim.
[`for(objectstring $classOrObject): LoggerInterface`](#for)

public function create(string $category): LoggerInterface

Returns a logger bound to the given category name verbatim.

Implementations must return a logger whose threshold and sinks come from the same configuration the Log facade uses, so an injected logger and a facade logger for the same category behave identically.

ParameterTypeDescription
$categorystring

Returns LoggerInterface

public function for(object|string $classOrObject): LoggerInterface

Returns a logger whose category is derived from a class name or instance.

Accepts either the object itself or its fully-qualified class name; implementations must map both to the same category.

ParameterTypeDescription
$classOrObject`object““string`

Returns LoggerInterface