Logs Clean Up
Contents |
Overview
![]() | This utility is included and preconfigured starting from PR15Q2. In previous releases it can be installed as external community module: [1]. |
Log tables are database tables that are used by Openbravo to keep logs. Usually these logs are no valuable after some period of time, but if they are not cleaned up they can cause database to increase it volume over time.
Default configuration
Openbravo provides a default standard configuration (see more details about Configuration in next section).
This configuration cleans the following tables up with the defined frequency:
Table | Keep records newer than n days/Filters | Notes |
AD_PInstance
| 15 days | Keeps track of process executions, deletions in this table cause also deletions in AD_PInstance_Para which stores information about parameter values used in each execution.
|
AD_Process_Request
| 15 days, only for completed requests | Table used to schedule processes, it typically grows up with immediate executions. |
AD_Process_Run
|
| Keeps information of executions of background scheduled processes |
AD_Session
| 40 days | Stores a record per each session in Openbravo. Deleting this table causes also deletions on AD_Session_Usage_Audit
|
Retail instances also include:
Table | Keep records newer than n days/Filters | Notes |
OBMOBC_LogClient
|
| Keeps track of logs client logs generated in WebPOS |
It also schedules a process to execute this clean up. It is scheduled to be run every Sunday at 0:00 (server local time).
Modifying default configuration
- Changes in the frequency of default configuration can be done by simply edition as System Admin these settings from Log Clean Up Configuration window.
- It is possible to preserve data in these tables by marking the configuration record for that specific table as inactive.
- The scheduling of the process can be changed by unscheduling it, change the settings and scheduling it again.
- In order to completely disable this functionality, just unschedule the process. (Do not delete it)
Configuration
After installing Log Clean Up Utility module, it requires to configure two things:
- Entities (tables) to be cleaned up
- Scheduled process to do the clean up
Entities
The entities to be processed are configured, as System Administrator role, from Log Clean Up Configuration window.
The fields in this window are:
- Log Table: The log table that will be processed to do the clean up.
- Older Than Days: Records in Log Table that are older than this number of days will be deleted by the process. In case the value of this field is 0, all records in the table will be removed.
- Date Column to Check: If it is set, Older Than Days value will be checked with this column. If it is not, Creation Date column will be used by default for this purpose.
- HQL Where Clause. A HQL where clause that allows to limit the number of records to be deleted. If it is set, the records to be deleted are the ones matching both, this where clause and the Older Than Days conditions. If it is not set, only Older Than Days will be taken into account.
- Truncate Table. When this flag is set, all data in the table will be completely removed, therefore it is not possible to define any other frequency nor HQL Where Clause. When wanting to always delete all data, this option performs better. Though, due to implementation it is not possible to mark a table to be truncated in case there are foreign keys linking to it. Because this definition can vary over the time when installing new modules, verification is done at run time when the process is executed. In case truncate is not possible, it will be marked in the log though the rest of configured entities will be tried to be cleaned up.
![]() | When creating the configuration it must ensured that Log Table is actually a table used for logging and not for any other purpose, as the process will remove records from it irrecoverably. |
Typical Log Tables
This is a list of the most common log tables included within Openbravo distribution (note other modules can add new ones).
-
AD_Process_Run
. Stores information about each execution of any scheduled process. -
AD_PInstance
. Stores information about each execution of any non-scheduled process. -
AD_Session
. Stores information about all sessions in Openbravo. -
AD_Session_Usage_Audit
. Stores statistical information about the commands executed by each Openbravo session.
Process
It is also required to schedule the Log Clean Up Process which is in charge of doing the clean up based on the configuration explained above.
To schedule it, create a new entry for Log Clean Up Process in Process_Request window. The best scheduling for this request might vary depending on how often the different entities are configured to be cleaned up. In any case, it is strongly advisable to set it up to be executed when Openbravo is not under an intensive usage (for example during the weekend) because this process can be highly demanding in database resources depending on the amount of information it requires to remove.
Data Level
Level of data to be removed depends on the Client and Organization the Process Request is defined in.
-In case the Request is at System level (client is System), all rows matching the criteria will be deleted regardless their Client/Organization. -In case the Request is at any other Client and/or Organization, records to be deleted will be filtered by that Client. Organization will be filtered by the ones below in the hierarchy to the selected one.
Entity Specific Implementations
It is possible to define specific actions to be executed when deleting data in an entity.
This can be achieved by extending org.openbravo.utility.cleanup.log.CleanEntity
class having a Qualifier
with the desired Entity Name. In this situation, clean
will be invoked, being possible to overwrite it with the specific actions.