Removing Or Editing Copyright Notice From The Footer In Magneto 2

Home / Magento2 / Removing Or Editing Copyright Notice From The Footer In Magneto 2

The development process is a complex matter. And as you create software, you might have lots of questions. And in this blog, we are trying to help you answer at least some of them.

Today, we will discuss the issue of creating a message to a system log. If you are looking for a way to create a custom variable or a system message with Magento 2, then here is how you can do it.

Programming is a straightforward industry: there are always clear ways to achieve specific goals. So, after you finish reading this article, you will have a solid understanding of the process. It is no easy rogerian essay topics. So, without further ado, let’s dive into the process itself.

What are logs?
First things first. Let’s clarify the definitions to make sure we are all on the same page.

Logs are used to track record of all data input and output, both major and minor processes in the program as well as its execution results. They help you see the processes that would otherwise be left unseen or unclear.

Thus, all the events in the system are stored in the form of logs. Later information stored there can be used for analysis. Like in the case of debugging, logs allow you to track the error, what led to them and when exactly it took place. So, when performing this operation, a developer has to use logs.

How to create a custom log in Magento 2 (OOP)

The main log facility class here is called “Magento\Framework\Logger\Monolog“. This is a log used by the system by default, and it is one of the most popular logging solutions. You can find it at “MAGENTO2_ROOT/vendor/monolog”.

In this case, the logger has its own set of handlers that can classified according to their functions:

  • files and system logger;
  • emails and notifications;
  • servers and network logger;
  • development logger;
  • DB log.

Each one of the handlers above either processes the message or sends it to the next handler in line.

Typically, Magento’s set of handlers are as follows:

  1. <preference for=”Psr\Log\LoggerInterface” type=”Magento\Framework\Logger\Monolog” />
  2. <type name=”Magento\Framework\Logger\Monolog”>
  3. <arguments>
  4. <argument name=”name” xsi:type=”string”>main</argument>
  5. <argument name=”handlers” xsi:type=”array”>
  6. <item name=”system” xsi:type=”object”>Magento\Framework\Logger\Handler\System</item>
  7. <item name=”debug” xsi:type=”object”>Magento\Framework\Logger\Handler\Debug</item>
  8. </argument>
  9. </arguments>
  10. </type>

There is an option of customizing the logic of this message by specifying your own set of handlers instead of “debug” and “system” ones mentioned above.

As simple as that, this logging method can be a great solution.

If you are willing to write a message to a system log in aspect-oriented programming, then you must remember that in this case business logic is separated from the service code (which in our case is logging).

For instance, here is what the logging logic combined with the business logic would look like:

  1. public function doSomething()
  2. {
  3. try {
  4. //do something
  5. } catch (\Exception $e) {
  6. $this->logger->critical($e);
  7. }
  8. }

Meanwhile, the code with the business logic alone would look like as follows:

  1. /**
  2. * @Logging
  3. */
  4. public function doSomething()
  5. {
  6. //do something
  7. }

If you need to write a message for a log in Magento 2 with method “critical”, you must use this snippet of code with the exception from try-catch:

// instance of $e will be converted to string (magic metod __toString() will be called).

According to the, all instances of classes go through class constructor. The code in this case would look like this:

namespace Inchoo\Test\Model;

class Example{
protected $_logger;
public function __construct(
\Psr\Log\LoggerInterface $logger, //log injection
array $data = []
) {
$this->_logger = $logger;

public function someExampleMethod() {
some logic of method
//accessing to logger instance and calling log method
$this->_logger->addDebug(‘some text or variable’);

All in all, logging in Magento 2 is possible thanks to the Monolog for logging. If you are trying to code this feature with Magento 2, then our article provides you with all the necessary information.

Should you have more questions, you can always contact us or drop us a line in the comments section. We will be happy to help you solve various programming-related issues.

Author’s Bio:

Kevin is a professional educator and a private tutor with over 8 years of experience. He is also a content writer for various blogs about higher education, entertainment, social media & blogging. During his off time, Kevin enjoys traveling and cooking. Feel free to connect with him on Twitter, Linkedin & Google+.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *