To view Sitecore logs in Log2Console is pretty easy. Sitecore Platform is using log4net and you can add an UdpAppender for logging in an external application.
On few blogs is described how to do it:
- https://community.sitecore.net/developers/f/8/t/136 ( few people described different tools for sitecore logs)
Sitecore Commerce is a .NET Core application, and is using Serilog for log messages.
We will use an external nuget package to send UDP package over the network: https://github.com/FantasticFiasco/serilog-sinks-udp
To view the commerce logs in Log2Console we need to follow next steps:
- Add a settings in commerce config.json to enable/disable sending UDP packages over the network.
2. Add reference to Serilog.Sinks.Udp nuget package
3. Modify commerce engine to use Serilog.Sink.Udp
The UDP packages are sent on port 7071.
At the end of Startup.cs add next code:
var writeToUdp = false;
//check if writotoUdp is enabled
if (bool.TryParse(Configuration.GetSection(“Serilog:WritetoUDP”).Value, out writeToUdp))
Log.Logger = new LoggerConfiguration()
.WriteTo.Udp(“localhost”, 7071, System.Net.Sockets.AddressFamily.InterNetwork)
4. Add a log2console receiver, it will work on port 7071.
and commerce logs will appear on Log2console