Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>Magento LoggerNew to Visual Studio Code? Get it now.
Magento Logger

Magento Logger

MayonnaiseSacoche

|
44 installs
| (0) | Free
Simple snippets to generate and use a Logger
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Magento Logger

This is the README for the Magento Logger snippet extension.

Features

Magento Logger allows you to easily generate a Logger and be able to use it.

Requirement

  • Require : Magento2
  • Language : PHP, PHTML

Use

Generate a Logger

To generate a Logger use:

>logger

This generates a Logger that looks like:

$writer = new \Zend_Log_Writer_Stream(BP . '/var/log/.log');
$logger = new \Zend_Log();
$logger->addWriter($writer);

The cursor appears in the middle of /var/log/{here}.log, write the name of the destination file here, or simply choose another file.

Write to the Logger

You must have already generated the Logger and be sure that it is accessible by your Magento program.

To write to a Logger write:

>logger

This generates a line info that looks like :

$logger->info();

The cursor appears in the middle of $logger->info({here}), write the thing to display, it must be of type string.

Follow the Logger

To follow the Logger message, execute this command in Linux:

tail -f {file}

Or in our example:

tail -f ./var/log/info.log
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft