restasp.net-web-api2odataserilogseq-logging

How to configure Serilog in Web Api 2 with OData v4


I am a beginner. I want to know how to Configure Serilog in RestApi to write logs to Seq. What should be the configurations in webapiconfig and Controller. and How to write log event for the same


Solution

  • First you need to install SEQ Server on your machine. The server registers itself as a service in your machine. This service runs on default port no 5341

    In the Global.asax file you need to create the instance of the logger.

    In the controller you can use variable Log to write the logs of various levels to seq server