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:
-
Access Configuration File:
- Open the
UiPath.Orchestrator.dll.config
file located in the UiPath Orchestrator installation directory.
- Open the
-
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 anotherINSERT
SQL command to log to the custom table. This should be placed within thetag, 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.