Enable database logging on groups and parameters

First I would say that I do NOT recommend to enable any database logging, unless it is business important for you, and you need to have a track of parameter changes.

But in some cases customers demand to have database logging.  I agreed and explained that it will have performance consequences, but we could do it on parameters and groups.

But I’m a type of guy that likes to create scripts to enable things.  So I wanted to share with you a small script that enables database logging on all groups and parameters.

(This script is for AX2009)

static void KHA_AddDatabaseLogging(Args _args)
    #AOT Name name;

    TreeNode treeNode;
    SysDictTable sysDictTable;
    DatabaseLog  DatabaseLog;
    treeNode = TreeNode::findNode(#TablesPath);
    treeNode = treeNode.AOTfirstChild();
    while (treeNode)
        name = treeNode.AOTname();
        sysDictTable = SysDictTable::newTableId(treeNode.applObjectId());

        if ((sysDictTable.tableGroup() == tableGroup::Parameter ||
             sysDictTable.tableGroup() == tableGroup::Group) &&
             !sysDictTable.isMap() &&
             !sysDictTable.isTmp() &&
             !sysDictTable.isView() &&
            select firstonly DatabaseLog where DatabaseLog.logTable == sysDictTable.id();
            if (!DatabaseLog)
                DatabaseLog.domainId = "Admin";
                DatabaseLog.logType  = DatabaseLogType::Update;
                DatabaseLog.logTable = sysDictTable.id();
                DatabaseLog.logField = 0;
            info(strfmt("Databaselogging enabled on %1",sysDictTable.name()));
        treeNode = treeNode.AOTnextSibling();

I appreciate that I can be a part of this worldwide blog community—as a consultant working from Norway, the blog lets me share more than 20 years of experience with Microsoft Dynamics 365. Along the way, I participated in developing retail, PDA/RF, barcoding, master data, kitting and WMS-solutions for Dynamics. My blog focuses on my deepest interests and expertise: along with a 360 degree view of digital transformation topics, I welcome opportunities to dive into retail and intercompany supply chain automation, logistics, and production—everything that is moving around in a truly connected enterprise. As Enterprise Architect on Dynamics 365, I specialize in strategic development and planning for corporate vertical solutions and works to build international networks that increase knowledge and understanding for Dynamics 365. As an advocate for both providers and customers, I'm committed to ensure that customers constantly changing needs are meet, and I see community as key for increasing expertise. I welcome you to connect with me.

4 comments on “Enable database logging on groups and parameters

  1. Pingback: Enable database logging on groups and parameters | Dynamics Ax 2009

  2. i need Enable database logging on groups and parameters for AX 2012


  3. You need to execute “SysFlushDatabaseLogSetup::main();” after insertion manually databaselog setup if you want that logging start directly. Otherwise, you must restart AOS to flush cache.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: