Setting Up Entity Log

You can set up entity log in the Administration → Entity Log application screen.

entity log set

Also, you can set up entity log by entering some records in the database if you want to include the configuration to the database initialization.

Logging is configured using the LoggedEntity and LoggedAttribute entities corresponding to AUDIT_LOGGED_ENTITY and AUDIT_LOGGED_ATTR tables.

LoggedEntity defines the types of entities that should be logged. LoggedEntity has the following attributes:

  • name – the name of the entity meta-class, for example, sample_Order.

  • auto – defines if the system should log the changes when EntityLog is called with auto = true parameter (called by entity listeners).

  • manual – defines if the system should log the changes when EntityLog is called with auto = false parameter.

LoggedAttribute defines the entity attribute to be logged and contains a link to the LoggedEntity and the attribute name.

To set up logging for a certain entity, add the corresponding entries into the AUDIT_LOGGED_ENTITY and AUDIT_LOGGED_ATTR tables.

In the example, logging changes of the phone attribute of the Customer entity is set up while database initialization:

<changeSet id="1" author="ex1">
    <insert tableName="AUDIT_LOGGED_ENTITY">
        <column name="ID" value="6c9e420a-2b7a-4c42-8654-a9027ee14083"/>
        <column name="CREATED_BY" value="admin"/>
        <column name="CREATE_TS" valueDate="2021-01-01T00:00:00"/>
        <column name="NAME" value="ex1_Customer"/>
        <column name="AUTO" value="true"/>
        <column name="MANUAL" value="true"/>
<changeSet id="2" author="ex1">
    <insert tableName="AUDIT_LOGGED_ATTR">
        <column name="ID" value="52a0126a-65bb-11eb-ae93-0242ac130002"/>
        <column name="CREATE_TS" valueDate="2021-01-01T00:00:00"/>
        <column name="CREATED_BY" value="admin"/>
        <column name="ENTITY_ID" value="6c9e420a-2b7a-4c42-8654-a9027ee14083"/>
        <column name="NAME" value="phone"/>