using NLog; using NLog.Targets; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SKMC.Api.Common.Logger { /// /// NLog 扩展 /// public class LoggingParameterTarget : TargetWithLayout { static readonly int LOGVIEW_MAXLINE = 1000; private readonly LogDataService logDataService = LogDataService.Instance(); protected override void Write(LogEventInfo loggingEvent) { logDataService.LogParameterModels.Insert(0, new LoggingEventModel(loggingEvent)); if (logDataService.LogParameterModels.Count == LOGVIEW_MAXLINE) { logDataService.LogParameterModels.RemoveAt(LOGVIEW_MAXLINE - 1); } } } }