using log4net.Core; using log4net.Layout.Pattern; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace VueWebApi.Log4net { public class ActionConverter: PatternLayoutConverter { protected override void Convert(System.IO.TextWriter writer, LoggingEvent loggingEvent) { var actionInfo = loggingEvent.MessageObject as ActionLoggerInfo; if (actionInfo == null) { writer.Write(""); } else { switch (this.Option.ToLower()) { case "op_type": writer.Write(actionInfo.op_type); break; case "op_content": writer.Write(actionInfo.op_content); break; case "actionclick": writer.Write(actionInfo.actionclick); break; case "ippath": writer.Write(actionInfo.ippath); break; case "lm_user": writer.Write(actionInfo.lm_user); break; default: writer.Write(""); break; } } } } }