Fluent API and own ILoggingFormatter

Topics: Logging Application Block
Jul 7, 2010 at 1:06 PM

How do I use fluent configuration together with a ILogFormatter that I've made?

Jul 8, 2010 at 4:06 AM

You can use the FormatterBuilder's CustomFormatterNamed method. See sample below;

            builder.ConfigureLogging()
                .WithOptions
                .DoNotRevertImpersonation()
                .LogToCategoryNamed("General")
                .WithOptions.SetAsDefaultCategory()
                .SendTo.FlatFile("Log File")
                .FormatWith(new FormatterBuilder()
                //MyCustomFormatter - custom LogFormatter
                                .CustomFormatterNamed<MyCustomFormatter>("Custom Formatter"))
                .ToFile("Log.log");

Gino Terrado
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com