What is the difference between AWS.Logger.Log4net vs AWS.Logger.AspNetCore

时间:2019-01-18 18:45:07

标签: c# amazon-web-services .net-core amazon-cloudwatch

This is for AWS cloud watch logging, one of my application is using AWS.Logger.Log4net with .NET Framework 4.7 which writes the logs in the AWS cloud-watch environment. We have a new requirement to develop a .NET Core 2.2 console application which needs to be deployed in an AWS batch job.

I am just confused between the AWS.Logger.Log4net and AWS.Logger.AspNetCore - can the AWS.Logger.Log4net be referenced in .NET Core 2.2 for logging, or do I need to use AWS.Logger.AspNetCore?

I just tried to reference the AWS.Logger.Log4net in the .NET Core application, looks like these Log4net API is not available for .NET Core:

  1. XmlConfigurator.Configure();
  2. (Hierarchy)LogManager.GetRepository();

I wanted to know my .Net core app should log the logs in Cloud watch, what can I use AWS.Logger.Log4net or AWS.Logger.AspNetCore?

1 个答案:

答案 0 :(得分:1)

I suppose AWS.Logger.Log4net works with the Log4net logging interfaces/sinks where AWS.Logger.AspNetCore provides a logger that works with Microsoft.Extensions.Logging.

I would suggest using AWS.Logger.AspNetCore since that depends on Microsoft.Extensions.Logging what the .NET Core libraries use.