public static IStructuredLoggingBuilder <TOptions> AddLayout <TOptions>(this IStructuredLoggingBuilder <TOptions> builder, ILayout layout) where TOptions : StructuredLoggingOptions, new() { if (layout == null) { throw new ArgumentNullException(nameof(layout)); } return(builder.AddLayout(GetName(layout.GetType()), _ => layout)); }
///////////////////////////////////////////////////////////////////////////// public static Tag _AddLayout( this Tag toTag, ILayout layout ) { //var properties = layout.GetType().GetRuntimeProperties().Where( pi => pi.PropertyType.; var type = layout.GetType(); var properties = type.GetProperties( BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly ); // // need to insert stuff in tag, but could be one or many // //toTag.AddChild() // layout.Initialize( toTag ); return toTag; }
public void Configure(ILayout layout, AttributeSet attributes) { var validationErrros = _attributeMatrix.Validate <ILayout>(attributes); if (validationErrros != null) { var message = "There are invalid attributes on layout of type " + layout.GetType().DisplayName(); if (attributes.IsLayout != null && string.IsNullOrEmpty(attributes.IsLayout.Name)) { message += " called '" + attributes.IsLayout.Name + "'."; } foreach (var error in validationErrros) { message += Environment.NewLine + error; } throw new LayoutBuilderException(message); } Configure((object)layout, attributes); }
public static string PreviewPattern(string InfoData, string LayoutType, string ConversionPattern, Object Host) { string sResult = string.Empty; StringWriter oWriter = new StringWriter(); LoggingEvent oEvent = new LoggingEvent(Host.GetType(), null, "Logger Name", Level.All, InfoData, null); ILayout oLayer = (ILayout)Assembly.Load(Constants.msCONST_LOG4NET_ASSEMBLY_NAME).CreateInstance(LayoutType); if (null == oLayer) { sResult = "This pattern layout is not supported. No preview work."; } else { if (oLayer.GetType() == typeof(PatternLayout)) { ((PatternLayout)oLayer).ConversionPattern = ConversionPattern; ((PatternLayout)oLayer).ActivateOptions(); } oLayer.Format(oWriter, oEvent); sResult = oWriter.GetStringBuilder().ToString(); } return(sResult); }
public override string ToString() { return($"Appender type: {GetType().Name}, Layout type: {layout.GetType().Name}, Report level: {ReportLevel}, Messages appended: {AppendedMessages}"); }
public override string ToString() { return($"Appender type: {GetType().Name}, Layout type: {layout.GetType().Name}," + $" Report level: {ReportLevel.ToString().ToUpper()}, Messages appended: {MessageCout}"); }
public override string ToString() { return($"Appender type: {this.GetType().Name}, Layout type: {layout.GetType().Name}, Report level: {ReportLevel.ToString().ToUpper()}, Messages appended: {AppendedMessages}, File size: {logFile.Size}"); }