Configuring What Historical Data is Logged
Comprehensively logging historical data can result in significant performance issues. As a result, when building blocks are deployed, the comprehensive logging of historical data is disabled. The logging of historical data is limited to only those actions that are required by other functionality. Out-of-the-box, the only historical data that is logged is the execution status of work definitions when they are created and updated.
You can configure the set of limited actions that are logged when comprehensive logging is disabled.
* 
If you choose to enable comprehensive logging, be aware that significant performance issues can result.
Configuring the Limited Set of Actions
To configure the limited set of actions that are logged when the comprehensive logging of historical data is disabled, complete the following steps:
1. Create a new building block that extends from the PTC.DBConnection building block.
To create your new building block, complete the following steps:
a. Create a new project. Use a unique prefix for your project, such as your company name. The PTC prefix is reserved for entities that are delivered by PTC. For this example, create a project named MyCompany.DBConnection. For each new Thing, Thing Template, or other entity that you create for this building block, add your new project as the Project value on the General Information for the entity in ThingWorx Composer.
b. Create a new Thing Template in your project that uses PTC.DefaultConfiguration.EntryPoint_TT as its Base Thing Template. For this example, name the new Thing Template MyCompany.DBConnection.EntryPoint_TT.
c. Create a new Thing in your project that uses the Thing Template created in step 1.b as its Base Thing Template. For this example, name the new Thing MyCompany.DBConnection.EntryPoint.
d. Create a new Thing Template in your project that uses the manager Thing Template from the PTC building block that you are extending from as its Base Thing Template. For this example, name the new Thing Template MyCompany.DBConnection.HistoricalDataManager_TT and use PTC.DBConnection.HistoricalDataManager_TT as its Base Thing Template.
e. Create a new Thing in your project that uses the Thing Template created in step 1.d as its Base Thing Template. For this example, name the new Thing MyCompany.DBConnection.Manager and use MyCompany.DBConnection.HistoricalDataManager_TT as its Base Thing Template.
* 
The PTC.DBConnection building block contains multiple manager Thing Templates and Things. The service to be overridden in this procedure is found on the PTC.DBConnection.HistoricalDataManager_TT. Ensure that you are using this manager Thing Template as the Base Thing Template for the new Thing Template that you are creating in this step, and not one of the other manager Thing Templates in the PTC.DBConnection building block.
2. Add any configurations from the manager Thing from the original building block to the manager Thing for your new building block.
a. Navigate to the manager Thing that you created in step 1.e, in this example MyCompany.DBConnection.HistoricalDataManager.
b. Under Configuration, add the same configurations that are found on the Configuration page for the manager Thing of the original building block, in this example, PTC.DBConnection.HistoricalDataManager.
3. Register the manager Thing of your new building block as the manager to use instead of the manager from the PTC building block that your building block extends from.
a. Navigate to the PTC.Base.Manager Thing.
b. Under Configuration, find the DefaultGlobalManagerConfiguration configuration table.
c. Click Edit icon. for the row with the managerThingName value that matches the manager of the PTC building block that your building block extends from.
For this example, click Edit icon. for the row with the managerThingName value of PTC.DBConnection.HistoricalDataManager.
d. In the edit window, set the manageThingName field to the name of the manager Thing for your building block that you created in step 1.e.
e. Click Set to set the new value.
f. Click Save to save the changes to the PTC.Base.Manager Thing.
4. In ThingWorx Composer, navigate to the historical data manager Thing Template for the your new building block that you created in step 1.d, in this example MyCompany.DBConnection.HistoricalDataManager_TT.
5. Under Services, find and override the GetHistoricalDataLogConfig service.
6. In the script editor, add an entry in the designated custom configuration area for each additional event that you want to be logged.
* 
Do not change or remove the default configuration entries which log the ExecutionStatus field value when work definitions (PTC.SCA.SCO.WorkDefinition) are created or updated without an understanding of the impacts on other functionality.
Entries use the following format:
addLoggingConfiguration("<Data_Shape>", "<field>", "<action>");
For each <action>, the possible <field> values are:
CREATE—The name of the field, ALL, or nothing
UPDATE—The name of the field or ALL
DELETE—Nothing (empty quotes)
The following table provides example entries for the different events that can be logged:
Event to be Logged
Example Entry
Creation of an entity (A row is added to the database table)
addLoggingConfiguration("PTC.SCA.SCO.WorkDefinition", "", "CREATE");
Creation of an entity and the initial value for each field (A row is added to the database table, and each field that has a value when the row is added)
addLoggingConfiguration("PTC.SCA.SCO.WorkDefinition", "ALL", "CREATE");
Initial value of a a specific field when the entity is created (The specified field has a value when the row is added to the database table)
addLoggingConfiguration("PTC.SCA.SCO.JobOrder", "ID", "CREATE");
Update of the value for a specific field (The specified field value changes in the database table)
addLoggingConfiguration("PTC.SCA.SCO.JobOrder", "PlannedEndTime", "UPDATE");
Update of the value for all fields (Any field value changes in the database table)
addLoggingConfiguration("PTC.SCA.SCO.JobOrder", "ALL", "UPDATE");
Deletion of an entity (A row is removed from the database table)
addLoggingConfiguration("PTC.SCA.SCO.JobOrder", "", "DELETE");
7. Click Done, then click Save to save the updated service.
Enabling Comprehensive Logging of Historical Data
To enable the comprehensive logging of historical data, complete the following steps:
* 
If you have previously completed the actions in steps 1 through 3, you do not need to repeat them. Proceed directly to step 4.
1. Create a new building block that extends from the PTC.DBConnection building block.
To create your new building block, complete the following steps:
a. Create a new project. Use a unique prefix for your project, such as your company name. The PTC prefix is reserved for entities that are delivered by PTC. For this example, create a project named MyCompany.DBConnection. For each new Thing, Thing Template, or other entity that you create for this building block, add your new project as the Project value on the General Information for the entity in ThingWorx Composer.
b. Create a new Thing Template in your project that uses PTC.DefaultConfiguration.EntryPoint_TT as its Base Thing Template. For this example, name the new Thing Template MyCompany.DBConnection.EntryPoint_TT.
c. Create a new Thing in your project that uses the Thing Template created in step 1.b as its Base Thing Template. For this example, name the new Thing MyCompany.DBConnection.EntryPoint.
d. Create a new Thing Template in your project that uses the manager Thing Template from the PTC building block that you are extending from as its Base Thing Template. For this example, name the new Thing Template MyCompany.DBConnection.HistoricalDataManager_TT and use PTC.DBConnection.HistoricalDataManager_TT as its Base Thing Template.
* 
The PTC.DBConnection building block contains multiple manager Thing Templates and Things. The service to be overridden in this procedure is found on the PTC.DBConnection.HistoricalDataManager_TT. Ensure that you are using this manager Thing Template as the Base Thing Template for the new Thing Template that you are creating in this step, and not one of the other manager Thing Templates in the PTC.DBConnection building block.
e. Create a new Thing in your project that uses the Thing Template created in step 1.d as its Base Thing Template. For this example, name the new Thing MyCompany.DBConnection.HistoricalDataManager and use MyCompany.DBConnection.HistoricalDataManager_TT as its Base Thing Template.
2. Add any configurations from the manager Thing from the original building block to the manager Thing for your new building block.
a. Navigate to the manager Thing that you created in step 1.e, in this example MyCompany.DBConnection.HistoricalDataManager.
b. Under Configuration, add the same configurations that are found on the Configuration page for the manager Thing of the original building block, in this example, PTC.DBConnection.HistoricalDataManager.
3. Register the manager Thing of your new building block as the manager to use instead of the manager from the PTC building block that your building block extends from.
a. Navigate to the PTC.Base.Manager Thing.
b. Under Configuration, find the DefaultGlobalManagerConfiguration configuration table.
c. Click Edit icon. for the row with the managerThingName value that matches the manager of the PTC building block that your building block extends from.
For this example, click Edit icon. for the row with the managerThingName value of PTC.DBConnection.HistoricalDataManager.
d. In the edit window, set the manageThingName field to the name of the manager Thing for your building block that you created in step 1.e.
e. Click Set to set the new value.
f. Click Save to save the changes to the PTC.Base.Manager Thing.
4. In ThingWorx Composer, navigate to the historical data manager Thing Template for the your new building block that you created in step 1.d, in this example MyCompany.DBConnection.HistoricalDataManager_TT.
5. Under Services, find and override the LogHistoricalData service.
6. In the script editor, change the false setting to true:
var result = true;
7. Click Done, then click Save to save the updated service.
Was this helpful?