var log = new LoggerConfiguration() .WriteTo.Console() .CreateLogger(); log.Information("Application started.");
var logger = NLog.LogManager.GetCurrentClassLogger(); logger.Info("Application started.");
var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); log.Info("Application started.");The above code generates the log instance by getting the current class's logger. The info method is used to capture log messages. Conclusion - Log4net, NLog, and Serilog are three of the popular open-source logging libraries available in C#. These frameworks offer a wide range of logging features, and you can choose based on your use case.