Skip to content

LoggerInterface

Alexander Saal edited this page Aug 4, 2025 · 1 revision

LoggerInterface

For logging the SDK uses the official Psr\Log\LoggerInterface.

If required, the LoggerInterface can be passed as parameter to the closure function and will then be automatically injected by the SDK.

The LoggerInterface defines several methods to log your application.

All Logs are written to the "custom_applications.log" in the output\log folder. The log level of JobRouter is applied.

Example

<?php

use JobRouter\Sdk\PathsInterface;
use Psr\Log\LoggerInterface;

return function (LoggerInterface $loggerInterface, PathsInterface $pathsInterface): void {
    echo '<h1 style="color: #fc0">JobRouter SDK logger interface example!</h1>';

    try {
        $loggerInterface->error('JobRouter URL: ' . $pathsInterface->getJobRouterUrl());
        $loggerInterface->warning('Data path: ' . $pathsInterface->getDataPath('extra/data/path', 'Example_Proccess', '1'));
        $loggerInterface->notice('Functions path: ' . $pathsInterface->getFunctionsPath());
        $loggerInterface->info('Temp path: ' . $pathsInterface->getTempPath());
        $loggerInterface->debug('Upload path: ' . $pathsInterface->getUploadPath());

        echo '<p style="color: #f44;">Message: All logs were written into ' . $pathsInterface->getOutputPath('log\custom_applications_' . date('ymd') . '.log') .  '</p>';
    } catch (\IllegalFilesystemAccessException|\JobRouterException $e) {
        echo '<h3 style="color: #f44;">JobRouter error!</h3>';
        echo '<p style="color: #f44;">Message: ' . $e->getMessage() .  '</p>';
    }
};

Response

JobRouter SDK logger interface example!

Message: All logs were written into /mnt/instancedata/output/log/custom_applications_250530.log

Clone this wiki locally