1

I'm trying to find out how to add custom event logging in the Magento 2 admin to log actions taken by our employees.

One of the reasons we've upgraded to the Enterprise edition is the addition of action logs, therefore I'd like to implement custom logging events, but I have no clue how to use it. Is there anyone out there who tried to do custom logging of actions?

Example:

One of our sales people updated one of the supplier's information, I'd like to see who did it on the next page:

<domain>/admin/admin/logging/index

How can I implement custom action logging?

1

It is possible to simply add Admin Logging to a module by adding a logging.xml and declare a group and afterwards enable this group in the configuration.

Stores > Settings > Configuration > Advanced > Admin > Admin Action Logs > Your Group Name

If you add a new one it will be disabled by default

Example of a logging.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. 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="group_identifier_here">
            <label translate="true">Action Group Label here</label>
            <expected_models>
                <expected_model class="Vendor\Module\Model\Class" />
            </expected_models>
            <events>
                <event controller_action="fullcontroller_actionname_here_save" action_alias="save" />
                <event controller_action="fullcontroller_actionname_here_delete"
                       action_alias="delete" />
            </events>
        </group>
    </groups>
</logging>
  • Thanks for the answer, this was the solution! Actually quite a nice solution, I thought it'd be a lot tougher. – Merijn Aug 31 '17 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.