ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/AnywhereTS-MSSQL/trunk/AnywhereTS.Logging/Logging.cs
(Generate patch)

Comparing trunk/AnywhereTS.Logging/Logging.cs (file contents):
Revision 69 by william, Thu Jul 12 14:32:21 2012 UTC vs.
Revision 70 by william, Thu Jul 12 20:47:35 2012 UTC

# Line 4 | Line 4 | using System.Text;
4   using log4net.Config;
5   using log4net;
6   using System.IO;
7 + using log4net.Util;
8 + using System.Reflection;
9 + using System.Collections;
10  
11   namespace AnywhereTS
12   {
# Line 16 | Line 19 | namespace AnywhereTS
19          public static readonly ILog ATSAdminLog = LogManager.GetLogger("AnywhereTS.ATSAmdin");
20          public static readonly ILog TSControlPanelLog = LogManager.GetLogger("AnywhereTS.TSControlPanel");
21          #endregion
22 +
23 +        #region log4net help
24 +        public static List<string> GetMessagesFromThreadContextStack(string RawContextStack)
25 +        {
26 +            try
27 +            {
28 +                ThreadContextStack tc = ThreadContext.Stacks[RawContextStack.ToUpper()];
29 +                if (tc == null) { return new List<string>(); }
30 +                else { return GetMessagesFromThreadContextStack(tc); }
31 +            }
32 +            catch { return new List<string>(); }            
33 +        }
34 +        public static List<string> GetMessagesFromThreadContextStack(ThreadContextStack rawTCS)
35 +        {
36 +            ThreadContextStack oldrawTCS = rawTCS;
37 +            List<string> stack_objects = new List<string>();
38 +          
39 +                ThreadContextStack context = (rawTCS as ThreadContextStack);
40 +                for (int i = 0; i < context.Count; i++)
41 +                {
42 +                    Type t = typeof(ThreadContextStack);
43 +                    MethodInfo mi = t.GetMethod("GetFullMessage", BindingFlags.NonPublic | BindingFlags.Instance);
44 +                    string message = mi.Invoke(context, null).ToString();
45 +                    stack_objects.Add(message);
46 +                    context.Pop();
47 +                }
48 +                rawTCS = oldrawTCS;            
49 +            return stack_objects;
50 +        }
51 +        #endregion
52      }
53   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines