View Sitecore xConnect logs in Log2Console

Few days ago I blogged about how to view Commerce logs in Log2Console.

I searched a little bit how to  view  xConnect logs in real time, but I didn’t find any article how to add a custom serilog sink.

I made a small research and here is there solution:

To view xConnect logs in Log2Console you need to follow next steps :

  1. Add Serilog.Sinks.UDP.dll and Serilog.Sinks.PeriodicBatching.dll to your xConnect bin folder . (https://github.com/FantasticFiasco/serilog-sinks-udp-sample-dotnet-framework)
  2.  Add a new Serilog configuration  into :     yourxConnectfolder\App_Data\Config\Sitecore\CoreServices and name it : sc.Serilog.Udp.xml where you set the remoteAddress and remotePort:
<?xml version="1.0" encoding="utf-8"?>
<Settings>
<Serilog>
<Using>
<UDPSinkAssembly>Serilog.Sinks.Udp</UDPSinkAssembly>
</Using>
<WriteTo>
<Udp>
<Name>Udp</Name>
<Args>
<remoteAddress>localhost</remoteAddress>
<remotePort>7071</remotePort>
</Args>
</Udp>
</WriteTo>
</Serilog>
</Settings>

3. To view xconnect logs from AutomationEngine, IndexWorker and ProcessEngine you need to copy above file  to the CoreServices folder (example  for IndexWorker : c:\inetpub\wwwroot\xconnectFolder\App_Data\jobs\continuous\IndexWorker\App_Data\config\sitecore\CoreServices\ )

4. Check log2console (I already setup the receivers)

log2consoleXconnect.PNG