/// <summary>
        /// Creates a <see cref="Formatter{T}"/> for all the entries in the <see cref="LogEntry.ExtendedProperties"/>
        /// dictionary.
        /// </summary>
        private static Formatter <LogEntry> DictionaryTokenHandlerFactory(string parameter)
        {
            Dictionary <string, TokenHandler <KeyValuePair <string, object> > > handlers
                = new Dictionary <string, TokenHandler <KeyValuePair <string, object> > >();

            handlers["newline"]
                = GenericTextFormatter <KeyValuePair <string, object> > .CreateSimpleTokenHandler(Environment.NewLine);

            handlers["tab"]
                = GenericTextFormatter <KeyValuePair <string, object> > .CreateSimpleTokenHandler("\t");

            handlers["key"]
                = GenericTextFormatter <KeyValuePair <string, object> > .CreateSimpleTokenHandler(kvp => kvp.Key);

            handlers["value"]
                = GenericTextFormatter <KeyValuePair <string, object> > .CreateSimpleTokenHandler(kvp => kvp.Value.ToString());

            GenericTextFormatter <KeyValuePair <string, object> > entryFormatter
                = new GenericTextFormatter <KeyValuePair <string, object> >(parameter, handlers);

            return(le =>
            {
                StringBuilder entries = new StringBuilder();

                foreach (var kvp in le.ExtendedProperties)
                {
                    entryFormatter.Format(kvp, entries);
                }

                return entries.ToString();
            });
        }
        /// <summary>
        /// Sets up the default token handlers for the <see cref="TextFormatter"/>;
        /// </summary>
        static TextFormatter()
        {
            defaultTokenHandlers    = new Dictionary <string, TokenHandler <LogEntry> >();
            emptyExtraTokenHandlers = new Dictionary <string, TokenHandler <LogEntry> >();

            // constants
            defaultTokenHandlers["newline"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(Environment.NewLine);

            defaultTokenHandlers["tab"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler("\t");

            // cached values
            defaultTokenHandlers["localMachine"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(LogEntryContext.GetMachineNameSafe());

            defaultTokenHandlers["localProcessName"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(LogEntryContext.GetProcessNameSafe());

            defaultTokenHandlers["localAppDomain"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(LogEntryContext.GetAppDomainNameSafe());

            defaultTokenHandlers["localProcessId"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(LogEntryContext.GetProcessIdSafe());

            // simple properties on log entry
            defaultTokenHandlers["message"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.Message);

            defaultTokenHandlers["category"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => FormatCategoriesCollection(le.Categories));

            defaultTokenHandlers["priority"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.Priority.ToString(CultureInfo.CurrentCulture));

            defaultTokenHandlers["eventid"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.EventId.ToString(CultureInfo.CurrentCulture));

            defaultTokenHandlers["severity"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => FormatSeverity(le.Severity));

            defaultTokenHandlers["title"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.Title);

            defaultTokenHandlers["errorMessages"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.ErrorMessages);

            defaultTokenHandlers["machine"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.MachineName);

            defaultTokenHandlers["appDomain"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.AppDomainName);

            defaultTokenHandlers["processId"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.ProcessId);

            defaultTokenHandlers["processName"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.ProcessName);

            defaultTokenHandlers["threadName"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.ManagedThreadName);

            defaultTokenHandlers["win32ThreadId"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.Win32ThreadId);

            defaultTokenHandlers["activity"]
                = GenericTextFormatter <LogEntry> .CreateSimpleTokenHandler(le => le.ActivityId.ToString("D", CultureInfo.CurrentCulture));

            // parameterized tokens
            defaultTokenHandlers["timestamp"]
                = GenericTextFormatter <LogEntry> .CreateParameterizedTokenHandler(TimestampFormatterFactory);

            defaultTokenHandlers["property"]
                = GenericTextFormatter <LogEntry> .CreateParameterizedTokenHandler(ReflectedPropertyFormatterFactory);

            defaultTokenHandlers["keyvalue"]
                = GenericTextFormatter <LogEntry> .CreateParameterizedTokenHandler(KeyValueFormatterFactory);

            defaultTokenHandlers["dictionary"]
                = GenericTextFormatter <LogEntry> .CreateParameterizedTokenHandler(DictionaryTokenHandlerFactory);
        }