How to get the Orchestrator jobs logs in Azure Application Insights?
Follow the below steps,
- Go to the Orchestrator App Service and under the Settings Option there is a Application Insights-> Click on Enable this will create the Application Insights automatically.
- Now go the App Service Editor under the Orchestrator App Service then click on Go. Refer the below screenshot.
- This will open other new windows with the Orchestrator directory file location
- From this window open the "UiPath.Orchestrator.dll.config" file
- Update the below highlighted values in the UiPath.Orchestrator.dll.config file
- After update the below highlighted values in the config file please restarted the Orchestrator and Identity service from the azure portal. This will help you to get the orchestrator jobs logs in Application Insights
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
<section name="secureAppSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="system.web" type="System.Configuration.IgnoreSection, System.Configuration.ConfigurationManager" allowLocation="false" />
<!-- IdentityProvider -->
<section name="ClientApplications" type="UiPath.Orchestrator.Security.IdentityProvider.Model.ClientApplications, UiPath.Orchestrator.Security.IdentityProvider" />
</configSections>
<connectionStrings>
<add name="Default" providerName="System.Data.SqlClient" connectionString="Server=.\;Database=UiPath;Integrated Security=True;" /> <add name="TestAutomation" providerName="System.Data.SqlClient" connectionString="Server=.\;Database=UiPathTestAutomation;Integrated Security=True;" />
</connectionStrings>
<!--Logging configuration-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" throwExceptions="false" internalLogLevel="Off" internalLogFile="">
<extensions>
<add assembly="NLog.Targets.ElasticSearch" />
<add assembly="NLog.Mongo" />
<add assembly="Microsoft.ApplicationInsights.NLogTarget" />
<!--TODO: add new UiPath.Orchestrator.Web (or whatever) top level assembly-->
</extensions>
<targets>
<default-wrapper xsi:type="UiPrettyExceptionWrapper" /> <target xsi:type="EventLog" name="eventLog" layout="${message}${onexception:${exception:format=tostring:maxInnerExceptionLevel=5:innerFormat=tostring}}" source="Orchestrator" log="Application" />
<target xsi:type="EventLog" name="businessExceptionEventLog" layout="${message}${onexception:${exception:format=tostring:maxInnerExceptionLevel=5:innerFormat=tostring}}" source="Orchestrator.BusinessException" log="Application" />
<target xsi:type="EventLog" name="eventLogQuartz" layout="[Quartz] ${message} ${onexception: ${exception:format=tostring:maxInnerExceptionLevel=5:innerFormat=tostring}}" source="Orchestrator" log="Application" />
<target name="robotElasticBuffer" xsi:type="BufferingWrapper" flushTimeout="5000">
<target xsi:type="ElasticSearch" name="robotElastic" uri="" requireAuth="false" username="" password="" index="${event-properties:item=indexName}-${date:format=yyyy.MM}" documentType="logEvent" includeAllProperties="true" layout="${message}" excludedProperties="agentSessionId,tenantId,indexName" />
</target>
<target name="serverElasticBuffer" xsi:type="BufferingWrapper" flushTimeout="5000">
<target xsi:type="ElasticSearch" name="serverElastic" uri="" requireAuth="false" username="" password="" index="" documentType="logEvent" includeAllProperties="true" layout="${machinename} ${message}" />
</target>
<target xsi:type="AsyncWrapper" name="database" overflowAction="Block" queueLimit="100" fullBatchSizeWriteLimit="2" batchSize="50" timeToSleepBetweenBatches="1">
<target xsi:type="Database" connectionString="${ui-connection-strings:item=Default}" keepConnection="true" isolationLevel="ReadCommitted">
<commandText>
INSERT INTO dbo.Logs (OrganizationUnitId, TenantId, TimeStamp, Level, WindowsIdentity, ProcessName, JobKey, Message, RawMessage, RobotName, MachineId, UserKey, HostMachineName)
VALUES (@organizationUnitId, @tenantId, @timeStamp, @level, @windowsIdentity, @processName, @jobId, @message, @rawMessage, @robotName, @machineId, @userKey, @hostMachineName)
</commandText>
<parameter name="@organizationUnitId" layout="${event-properties:item=organizationUnitId}" />
<parameter name="@tenantId" layout="${event-properties:item=tenantId}" />
<parameter name="@timeStamp" layout="${date:format=yyyy-MM-dd HH\:mm\:ss.fff}" />
<parameter name="@level" layout="${event-properties:item=levelOrdinal}" />
<parameter name="@windowsIdentity" layout="${event-properties:item=windowsIdentity}" />
<parameter name="@processName" layout="${event-properties:item=processName}" />
<parameter name="@jobId" layout="${event-properties:item=jobId}" />
<parameter name="@message" layout="${message}" />
<parameter name="@rawMessage" layout="${event-properties:item=rawMessage}" />
<parameter name="@robotName" layout="${event-properties:item=robotName}" />
<parameter name="@machineId" layout="${event-properties:item=machineId}" />
<parameter name="@userKey" layout="${event-properties:item=userKey}" />
<parameter name="@hostMachineName" layout="${event-properties:item=machineName}" />
</target>
</target>
<target xsi:type="BufferingWrapper" name="monitoring" bufferSize="100" flushTimeout="5000" slidingTimeout="false">
<target xsi:type="Database" connectionString="${ui-connection-strings:item=Default}" keepConnection="true">
<commandText>
insert into stats.ErrorLogs (OrganizationUnitId, TenantId, TimeStamp, CorrelationId, Source, Level, RobotId, ProcessName, JobKey, QueueDefinitionId, Message)
values (@organizationUnitId, @tenantId, @timestamp, @correlationId, @logSource, @level, @robotId, @processName, @jobId, @queueId, @message)
</commandText>
<parameter name="@organizationUnitId" layout="${event-properties:item=organizationUnitId}" />
<parameter name="@tenantId" layout="${event-properties:item=tenantId}" />
<parameter name="@timestamp" layout="${date:format=yyyy-MM-dd HH\:mm\:ss.fff}" />
<parameter name="@correlationId" layout="${event-properties:item=Correlation}" />
<parameter name="@logSource" layout="${event-properties:item=logSource}" />
<parameter name="@level" layout="${event-properties:item=levelOrdinal}" />
<parameter name="@robotId" layout="${event-properties:item=robotId}" />
<parameter name="@processName" layout="${event-properties:item=processName}" />
<parameter name="@jobId" layout="${event-properties:item=jobId}" />
<parameter name="@queueId" layout="${event-properties:item=queueId}" />
<parameter name="@message" layout="${message}" />
</target>
</target>
<target xsi:type="BufferingWrapper" name="insightsRobotLogs" bufferSize="100" flushTimeout="5000" slidingTimeout="false">
<target xsi:type="Database" connectionString="${ui-connection-strings:item=Insights}" keepConnection="true">
<commandText>
insert into dbo.RobotLogs (OrganizationUnitId, TenantId, TimeStamp, WindowsIdentity, ProcessName, JobKey, RawMessage, RobotName, MachineId, Message, LevelOrdinal, NumCustomFields)
values (@organizationUnitId, @tenantId, @timeStamp, @windowsIdentity, @processName, @jobId, @rawMessage, @robotName, @machineId, @message, @levelOrdinal, @numCustomFields)
</commandText>
<parameter name="@organizationUnitId" layout="${event-properties:item=organizationUnitId}" />
<parameter name="@tenantId" layout="${event-properties:item=tenantId}" />
<parameter name="@timeStamp" layout="${date:format=yyyy-MM-dd HH\:mm\:ss.fff}" />
<parameter name="@windowsIdentity" layout="${event-properties:item=windowsIdentity}" />
<parameter name="@processName" layout="${event-properties:item=processName}" />
<parameter name="@jobId" layout="${event-properties:item=jobId}" />
<parameter name="@rawMessage" layout="${event-properties:item=rawMessage}" />
<parameter name="@robotName" layout="${event-properties:item=robotName}" />
<parameter name="@machineId" layout="${event-properties:item=machineId}" />
<parameter name="@message" layout="${message}" />
<parameter name="@levelOrdinal" layout="${event-properties:item=levelOrdinal}" />
<parameter name="@numCustomFields" layout="${ui-robot-logs-num-custom-fields}" />
</target>
</target>
<target xsi:type="ApplicationInsightsTarget" name="aiTarget" />
</targets>
<rules>
<logger name="Robot.*" ruleName="insightsRobotLogsRule" enabled="false" minlevel="Info" writeTo="insightsRobotLogs">
<filters defaultAction="Ignore">
<when condition="level >= LogLevel.Error or ends-with('${message}',' execution ended')" action="Log" />
</filters>
</logger>
<logger name="BusinessException.*" minlevel="Info" writeTo="businessExceptionEventLog,aiTarget" final="true" />
<logger name="Robot.*" ruleName="primaryRobotLogsTarget" writeTo="database,robotElasticBuffer,aiTarget" final="true" />
<logger name="Monitoring.*" writeTo="monitoring" minlevel="Warn" final="true" />
<logger name="Quartz.*" minlevel="Warn" writeTo="eventLogQuartz,aiTarget" final="true" />
<logger name="*" minlevel="Info" writeTo="eventLog,aiTarget" />
</rules>
</nlog>
- After restart the Orchestrator and Identity services, execute the process from Orchestrator and check the Application Insights Log page you will get the logs Eg: Refer the below screenshot.
Note: The old jobs logs will not be received, only the recent logs will be received.