/// <summary>
        /// Add the standard (in the opinion of this class) conversions.
        /// </summary>
        /// <remarks>
        /// <para>
        /// TODO: (Rant) I'm not entirely happy with this monster.
        /// I wish s_globalRulesRegistry and friends in <seealso cref="PatternLayout"/>
        /// would better lend themselves to code reuse.
        /// There could be a simple ConvertorCollection class exposing that functionality
        /// which I'd re-use to create the following matrix with the already declared convertors.
        /// </para>
        /// </remarks>
        /// <param name="calls">calls to add to</param>
        /// <returns>calls added</returns>
        private static IEnumerable <RawCallLayout> MakeOverrideCalls(IEnumerable <RawCallLayout> calls)
        {
            var env = new EnvAccess() as IEnvAccess;

            // these calls should grab the same info as log4net would, but try to get it in raw format so that
            // value is serialized later by a specific serializer.
            RawCallLayout.AddCalls(ref calls, e => e.TimeStamp.ToUniversalTime().ToString("o"), "utcdate", "utcDate", "UtcDate");
            RawCallLayout.AddCalls(ref calls, e => e.TimeStamp.ToString("o"), "date", "d");
            RawCallLayout.AddCalls(ref calls, e => e.Level.DisplayName, "level", "p");
            RawCallLayout.AddCalls(ref calls, e => e.LoggerName, "logger", "c");
            RawCallLayout.AddCalls(ref calls, e => e.ThreadName, "thread", "t");
            RawCallLayout.AddCalls(ref calls, e => e.RenderedMessage, "message", "raw_event" /*custom*/, "m");
            RawCallLayout.AddCalls(ref calls, e => e.MessageObject, "messageobject" /*custom*/, "mo" /*custom*/);
            RawCallLayout.AddCalls(ref calls, e => e.ExceptionObject == null ? null : e.GetExceptionString(), "exception", "e" /*custom*/);
            RawCallLayout.AddCalls(ref calls, e => e.ExceptionObject, "exceptionobject" /*custom*/, "eo" /*custom*/);
            RawCallLayout.AddCalls(ref calls, e => e.Identity, "identity", "u");
            RawCallLayout.AddCalls(ref calls, e => e.UserName, "username", "w");

            RawCallLayout.AddCalls(ref calls, e => e.GetProperties(), "property", "properties", "mdc", "P", "X");

            RawCallLayout.AddCalls(ref calls, e => e.LookupProperty("NDC"), "ndc", "x");
            RawCallLayout.AddCalls(ref calls, e => e.Domain, "appdomain", "a");
            RawCallLayout.AddCalls(ref calls, e => env.GetAppPath(), "apppath" /*custom*/);
            RawCallLayout.AddCalls(ref calls, e => env.GetAppName(), "appname" /*custom*/);

            RawCallLayout.AddCalls(ref calls, e => e.LocationInformation.ClassName, "type", "class", "C");
            RawCallLayout.AddCalls(ref calls, e => e.LocationInformation.FileName, "file", "F");
            RawCallLayout.AddCalls(ref calls, e => e.LocationInformation.FullInfo, "location", "l");
            RawCallLayout.AddCalls(ref calls, e => e.LocationInformation.LineNumber, "line", "L");
            RawCallLayout.AddCalls(ref calls, e => e.LocationInformation.MethodName, "method", "M");
            RawCallLayout.AddCalls(ref calls, e => (e.TimeStamp - LoggingEvent.StartTime).TotalMilliseconds, "timestamp", "r");
            RawCallLayout.AddCalls(ref calls, e => Environment.NewLine, "newline", "n");
            RawCallLayout.AddCalls(ref calls, e => env.GetProcessId(), "processid" /*custom*/, "pid" /*custom*/);
            RawCallLayout.AddCalls(ref calls, e => env.GetMachineName(), "hostname" /*custom*/, "h" /*custom*/);
            RawCallLayout.AddCalls(ref calls, e => e.UserName, "user" /*custom*/);
            RawCallLayout.AddCalls(ref calls, e => env.GetUserDomain(), "domain" /*custom*/);
            RawCallLayout.AddCalls(ref calls, e => env.GetCommandLine(), "commandline" /*custom*/);
            RawCallLayout.AddCalls(ref calls, e => env.GetWorkingSet(), "memory" /*custom*/);

            return(calls);
        }
Exemple #2
0
 /// <summary>
 /// A universal stamp with name "stamp"
 /// </summary>
 public Stamp()
 {
     _env = new EnvAccess() as IEnvAccess;
 }