| 1234567891011121314151617181920212223242526272829303132333435 |
- using log4net.Appender;
- using log4net.Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SKMC.Api.Common
- {
- /// <summary>
- /// log4net 扩展
- /// </summary>
- public class LoggingEventAppender : AppenderSkeleton
- {
- static readonly int LOGVIEW_MAXLINE = 1000;
- private readonly LogDataService logDataService = LogDataService.Instance();
- protected override void Append(LoggingEvent loggingEvent)
- {
- //logDataService.LogEventModels.Insert(0, new LoggingEventModel(loggingEvent));
- //if (logDataService.LogEventModels.Count == LOGVIEW_MAXLINE)
- //{
- // logDataService.LogEventModels.RemoveAt(LOGVIEW_MAXLINE - 1);
- //}
- logDataService.LogEventModels.Add(new LoggingEventModel(loggingEvent));
- if (logDataService.LogEventModels.Count == LOGVIEW_MAXLINE)
- {
- logDataService.LogEventModels.RemoveAt(0);
- }
- }
- }
- }
|