Magento, Magento 2

Adobe Commerce | Magento 2 : How to Add Custom Events Logging in the Admin Action Log

Admin Actions Report in Magento 2

In this tutorial, Today I will explain you how to add custom events or actions logging in the Admin Action Log Reports in Adobe Commerce or Magento 2 Commerce. Action Logs Report is exclusive features provided by Adobe Commerce only. It is used to display a details record of all Admin actions.

In the admin site, there are admin action log grid is also available. Using that grid, you can see action, ip address, admin user details etc.

To view the Admin Action Logs Report :

  • Go to Admin -> System -> Admin Logs -> Report

You may also like this :

Now, question is that if you develop any custom functionality which is related to admin panel then, how to add custom events logging in the admin action log reports.

Step to How to Add Custom Events or Actions Logging in the Admin Action Log Reports

For that, You need to create logging.xml file at app/code/RH/Helloworld/etc/ and paste the below code :

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<logging xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Logging:etc/logging.xsd">
    <groups>
        <group name="rh_helloworld">
            <label translate="true">RH Helloworld Log</label>
            <expected_models>
                <expected_model class="RH\Helloworld\Model\CustomerGrid" />
            </expected_models>
            <events>
                <event controller_action="rh_helloworld_index"
                       action_alias="productLogIndex" />
            </events>
        </group>
    </groups>
</logging>

Here, you can see attributes details of logging.xml file

  • group_name : set group identifier here.
  • expected_models : set model class path
  • controller_action : set controller action
  • action_alias : set alias of the action

In the store configuration, Go to below path :

Store -> Configuration -> Advanced -> Admin -> Admin Actions Logging

Here, RH Helloworld Log action record should be there and checkbox must be checked.

Action_Logs_Config

That’s it !!!

I hope this blog is easy to understand about how to add custom events or actions logging in the Admin Action Log Reports in Adobe Commerce or Magento 2 Commerce. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.

Keep liking and sharing !!

Tagged , ,