Table of Contents

Class TextFormatter

Namespace
Microsoft.Practices.EnterpriseLibrary.Logging.Formatters
Assembly
Microsoft.Practices.EnterpriseLibrary.Logging.dll

Represents a template based formatter for LogEntry messages.

public class TextFormatter : LogFormatter, ILogFormatter
Inheritance
TextFormatter
Implements
Inherited Members

Remarks

The TextFormatter uses a GenericTextFormatter<T> initialized with a set of TokenHandler<T> that can manage the default template tokens. Subclasses can supply extra token handlers that will be added to the default set for additional template processing.

Constructors

TextFormatter()

Initializes a new instance of a TextFormatter with a default template.

public TextFormatter()
See Also

TextFormatter(string)

Initializes a new instance of a with a template and no extra token handlers.

public TextFormatter(string template)

Parameters

template string

Template to be used when formatting.

See Also

TextFormatter(string, IDictionary<string, TokenHandler<LogEntry>>)

Initializes a new instance of a with a template and additional token handlers.

protected TextFormatter(string template, IDictionary<string, TokenHandler<LogEntry>> extraTokenHandlers)

Parameters

template string

Template to be used when formatting.

extraTokenHandlers IDictionary<string, TokenHandler<LogEntry>>

The additional token handlers to use when processing the template.

See Also

Properties

DefaultTextFormat

Gets the default format to use when formatting.

public static string DefaultTextFormat { get; }

Property Value

string
See Also

Template

Gets or sets the formatting template.

public string Template { get; set; }

Property Value

string
See Also

Methods

Format(LogEntry)

Formats the LogEntry object by replacing tokens with values.

public override string Format(LogEntry log)

Parameters

log LogEntry

Log entry to format.

Returns

string

Formatted string with tokens replaced with property values.

See Also

FormatCategoriesCollection(ICollection<string>)

Provides a textual representation of a categories list.

public static string FormatCategoriesCollection(ICollection<string> categories)

Parameters

categories ICollection<string>

The collection of categories.

Returns

string

A comma delimited textural representation of the categories.

See Also

FormatFixedIsoDate(DateTime)

Generates ISO format yyyy-MM-dd

public static string FormatFixedIsoDate(DateTime date)

Parameters

date DateTime

The date time to format.

Returns

string

A formatted date in the format yyyy-MM-dd

See Also

FormatFixedTime(DateTime)

Formats a date time with a fixed time format in a performant way.

public static string FormatFixedTime(DateTime date)

Parameters

date DateTime

The date time to format.

Returns

string

A formatted time in the format HH:mm:ss.fff

See Also

FormatFixedUSDate(DateTime)

Formats a date time with a fixed US date format in a performant way.

public static string FormatFixedUSDate(DateTime date)

Parameters

date DateTime

The date time to format.

Returns

string

A formatted date in the format MM/dd/yyyy

See Also

See Also