/// <summary> /// Register a custom layout renderer with a callback function <paramref name="layoutMethod"/>. The callback receives the logEvent and the current configuration. /// </summary> /// <param name="setupBuilder">Fluent interface parameter.</param> /// <param name="name">Name of the layout renderer - without ${}.</param> /// <param name="layoutMethod">Callback that returns the value for the layout renderer.</param> public static ISetupExtensionsBuilder RegisterLayoutRenderer(this ISetupExtensionsBuilder setupBuilder, string name, Func <LogEventInfo, LoggingConfiguration, object> layoutMethod) { var layoutRenderer = new FuncLayoutRenderer(name, layoutMethod); ConfigurationItemFactory.Default.GetLayoutRenderers().RegisterFuncLayout(name, layoutRenderer); return(setupBuilder); }
/// <summary> /// Register a layout renderer with a callback function. /// </summary> /// <param name="name">Name of the layoutrenderer, without ${}.</param> /// <param name="renderer">the renderer that renders the value.</param> public void RegisterFuncLayout(string name, FuncLayoutRenderer renderer) { _funcRenderers = _funcRenderers ?? new Dictionary <string, FuncLayoutRenderer>(StringComparer.OrdinalIgnoreCase); //overwrite current if there is one _funcRenderers[name] = renderer; }
/// <summary> /// Register a custom layout renderer with a callback function <paramref name="layoutMethod"/>. The callback receives the logEvent and the current configuration. /// </summary> /// <param name="setupBuilder">Fluent interface parameter.</param> /// <param name="name">Name of the layout renderer - without ${}.</param> /// <param name="layoutMethod">Callback that returns the value for the layout renderer.</param> /// <param name="options">Options of the layout renderer.</param> public static ISetupExtensionsBuilder RegisterLayoutRenderer(this ISetupExtensionsBuilder setupBuilder, string name, Func <LogEventInfo, LoggingConfiguration, object> layoutMethod, LayoutRenderOptions options) { FuncLayoutRenderer layoutRenderer = Layout.CreateFuncLayoutRenderer(layoutMethod, options, name); setupBuilder.LogFactory.ServiceRepository.ConfigurationItemFactory.GetLayoutRenderers().RegisterFuncLayout(name, layoutRenderer); return(setupBuilder); }