Hello, Magento Folks,

Last time we learned how you can load products from ID and SKU. Today, we are going to talk about how you can create a custom log file using a module in Magento 2.

Logging is an essential part that provides insights for various system-related processes in Magento 2. With log data, you can easily track errors, important events, exceptions, and more. When we are creating a website or a module on Magento 2, it is very important that we also create a log file to monitor/debug the errors.

Default Magento 2 comes with built logging components based on the monolog library. But today, we are going to see how you can create a custom log file using module programmatically in Magento 2. So, without further ado, let’s get started.

First, create a custom log file at the below path:

1.create file at given below path:


2.create second file at given below path:


3.create Third file at given below path:


4.create fourth file at given below path:


5.create fifth file at given below path:


6.create sixth file at given below path:


After running this module, Your file will be generated on below path -Magento2_root_directory\var\log\vendor_extension_log_file.log

So, this was it for the day. You can implement and customize these codes right away as per your needs. If you face any problem while implementation, then you can get in touch with us at our support desk.

Lastly, please share this with your Magento partners and let us know what they feel about this.

Happy Coding!

Click to rate this post!
[Total: 4 Average: 4]