I've upgraded lumen from 5.8 to 9.1 and php from 7.x to 8.1
In my env we load json logs to kibana, but after update log format has changed to something like this:
2022-11-08 11:56:47 App\Domain\Email\Listeners\MoveEmailToProcessed{"message":"Marked email as processed","context":{"object_key":"incoming/0i02qrl9t4llea3fhfm2t6184r3nv9rs7nb4cu01","email":"[email protected]"},"level":200,"level_name":"INFO","channel":"production","datetime":"2022-11-08T11:56:48.006053+00:00","extra":{}}
447.64ms DONE
while it was and should stay raw JSON like this:
{"message":"Marked email as processed","context":{"object_key":"incoming/0i02qrl9t4llea3fhfm2t6184r3nv9rs7nb4cu01","email":"[email protected]"},"level":200,"level_name":"INFO","channel":"production","datetime":"2022-11-08T11:56:48.006053+00:00","extra":{}}
I have config for this as different channel in lumen using monolog:
'stdout-json' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'with' => [
'stream' => 'php://stdout',
],
'formatter' => Monolog\Formatter\JsonFormatter::class,
],
And since format has changed it don't end up in kibana as expected. Question is what am I missing? Config didn't changed and I didn't saw anything specific in any upgrade guide I was following. Any idea what might be wrong?
Oh, and I don't use any lumen 'shortcuts' so logger is injected as it should. So code looks like this i.e.
public function __construct(Cloud $s3, LoggerInterface $logger)
{
$this->s3 = $s3;
$this->logger = $logger;
}
public function handle(EmailProcessed $emailProcessed): void
{
$filename = explode('/', $emailProcessed->getObjectKey())[1];
$newPath = sprintf('%s/%s', self::PROCESSED_DIR, $filename);
if ($this->s3->exists($newPath)) {
$this->s3->delete($newPath);
}
$this->s3->move($emailProcessed->getObjectKey(), $newPath);
$this->logger->info(
'Marked email as processed',
[
'object_key' => $emailProcessed->getObjectKey(),
'email' => $emailProcessed->getEmail(),
]
);
}
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.