Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / MSD365 F&O Learning / How to clean database log i...

How to clean database log in Microsoft Dynamics 365 F&SC

Introduction

Clients consistently require periodic cleanup of the database logs, as these logs accumulate significant data over time, consuming substantial storage space and ultimately slowing down system performance. So this cleanup routine lets you delete database logs as you require. You can delete logs for specific tables, delete specific types of database logs, or delete logs based on the date and time when they were created.

Relevance of Database Log Clean up

1. Performance Optimization:
Regular cleanup of logs helps in maintaining optimal system performance by reducing the size of the database and preventing unnecessary data accumulation.

2. Compliance and Security:
Ensuring that only necessary logs are retained helps in complying with data retention policies and enhances security by minimizing the risk of sensitive data exposure.

3. Efficient Resource Management:
By cleaning up logs, you free up valuable storage space and resources, which can be utilized for other critical business operations.

4. System Maintenance:
Regular log cleanup is part of good system maintenance practices, ensuring that the system runs smoothly and efficiently

Configuration

1. Go to System administration > Inquiries > Database > Database log > Clean up Log


2. Choose the method to select the logs that need to be deleted. You can filter logs based on:
  • Table ID: Specify the table ID that the logs refer to.
  • Log Type: Select the type of log (e.g., insert, update, delete).
  • Creation Date and Time: Filter logs based on when they were created.




Process to clean up the log

1. Below SS is the database log created during the period of business processes. In this example we will delete these database log history for the type of change Insert only.
Based on current date (i.e. 25-08-2024) Clean up log filter will be set and run.
Database log Date: 26-07-2024
Today's Date (Current Date): 25-08-2024
Clean up log filter date: (LessThanDate(-29))
Note: Above filter will consider the date 26-07-2024 and older on which database log is created (25/08/2024 - 26/07/2024 -1 = 29 days (today's date is excluded)) 



2. To set filter query to delete delete the database log 



3. Run the clean up log batch job it will delete the database log for the date 26-07-2024 and older.



4. To check the Clean up log batch job


5. To check the Database log table: It has deleted the selected record i.e "Insert" and left "Update" for the reference table ID 2580.


Bonus

1. Recurrence can be set if a company wants to clean database log for older that one year in that case keep the below setup:
- Reference Table ID: Blank ( it will apply to all log table)
- Log Type: Blank (it will apply to all log type)
- Created date and time: "(LessThanDate(-365))"

Set the recurrence pattern year and repeat once a year and keep the start date as first date of the next year.

     

NOTE: ABOVE CLEAN UP LOG SETUP CAN BE MODIFIED AS PER BUSINESS REQUIREMENT.

2. Advanced date queries that use SysQueryRangeUtil methods




Thank You!
Happy Learning😊


Reference:

Comments