How To Write The Custom Log To Another Table

How to write the custom log to another table, while the default logs are also written to the dbo.logs table?

Issue description:

In some scenarios, it may be necessary to log information to a custom table while still maintaining the default logging behavior in the dbo.Logs table. This can be achieved by modifying the UiPath.Orchestrator.dll.config file to include additional SQL commands for custom logging.

Resolution:

  1. Access Configuration File:

    • Open the UiPath.Orchestrator.dll.config file located in the UiPath Orchestrator installation directory.
  2. Locate the Logging Configuration:

    • Search for the following section within the configuration file:
   
      
         INSERT INTO dbo.Logs (OrganizationUnitId, TenantId, TimeStamp, Level, WindowsIdentity, ProcessName, JobKey, Message, RawMessage, RobotName, MachineId, UserKey)
         VALUES (@organizationUnitId, @tenantId, @timeStamp, @level, @windowsIdentity, @processName, @jobId, @message, @rawMessage, @robotName, @machineId, @userKey)
      
      
      
      
      
      
      
      
      
      
      
      
      
   

3. Add Custom Logging SQL Command:

  • After the default INSERT INTO dbo.Logs SQL command, add another INSERT SQL command to log to the custom table. This should be placed within the tag, following the existing SQL statement. Example (bold):

INSERT INTO dbo.Logs (OrganizationUnitId, TenantId, TimeStamp, Level, WindowsIdentity, ProcessName, JobKey, Message, RawMessage, RobotName, MachineId, UserKey)
VALUES (@organizationUnitId, @tenantId, @timeStamp, @level, @windowsIdentity, @processName, @jobId, @message, @rawMessage, @robotName, @machineId, @userKey);

INSERT INTO CustomLogsTable (CustomField1, CustomField2, CustomField3)
VALUES (@customValue1, @customValue2, @customValue3);

Important Note:

  • Do not use UiPath-defined tables for writing custom logs. Instead, define and use separate custom tables to avoid potential conflicts or issues with future UiPath updates.