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 LoggingActionTarget : TargetWithLayout { static readonly int LOGVIEW_MAXLINE = 1000; private readonly LogDataService logDataService = LogDataService.Instance(); protected override void Write(LogEventInfo loggingEvent) { logDataService.LogActionModels.Insert(0, new LoggingEventModel(loggingEvent)); if (logDataService.LogActionModels.Count == LOGVIEW_MAXLINE) { logDataService.LogActionModels.RemoveAt(LOGVIEW_MAXLINE - 1); } } } }