private MemoryTargetWrapper CreateRepository(LogLevel minimumLogLevel) { Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository(GetType().Assembly); PatternLayout patternLayout = new PatternLayout { ConversionPattern = "%m %exception" }; patternLayout.ActivateOptions(); var memoryAppender = new global::log4net.Appender.MemoryAppender { Threshold = _splat2log4net[minimumLogLevel], Layout = new PatternLayout { ConversionPattern = "%m %exception" }, }; memoryAppender.ActivateOptions(); var memoryWrapper = new MemoryTargetWrapper(memoryAppender); memoryWrapper.MemoryTarget.ActivateOptions(); hierarchy.Root.AddAppender(memoryWrapper.MemoryTarget); hierarchy.Root.Level = _splat2log4net[minimumLogLevel]; hierarchy.Configured = true; return(memoryWrapper); }
private static (global::log4net.ILog Logger, global::log4net.Appender.MemoryAppender MemoryTarget) GetActualLog4NetLoggerAndMemoryTarget() { var logger = LogManager.GetLogger(typeof(Log4NetLoggerTests)); var hierarchyLogger = (log4net.Repository.Hierarchy.Logger)logger.Logger; hierarchyLogger.Level = Level.All; var memory = new global::log4net.Appender.MemoryAppender { Threshold = Level.All, Layout = new PatternLayout { ConversionPattern = "%m" } }; memory.ActivateOptions(); hierarchyLogger.AddAppender(memory); hierarchyLogger.Repository.Configured = true; return(logger, memory); }
public MemoryTargetWrapper(global::log4net.Appender.MemoryAppender memoryTarget) { MemoryTarget = memoryTarget; }