/[AnywhereTS-MSSQL]/trunk/AnywhereTS.Logging/Logging.cs
ViewVC logotype

Diff of /trunk/AnywhereTS.Logging/Logging.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 48 by william, Thu Jul 12 14:32:21 2012 UTC revision 147 by william, Sun Jul 15 08:43:40 2012 UTC
# Line 4  using System.Text; Line 4  using System.Text;
4  using log4net.Config;  using log4net.Config;
5  using log4net;  using log4net;
6  using System.IO;  using System.IO;
7    using log4net.Util;
8    using System.Reflection;
9    using System.Collections;
10    
11  namespace AnywhereTS  namespace AnywhereTS
12  {  {
# Line 15  namespace AnywhereTS Line 18  namespace AnywhereTS
18          #region Log access          #region Log access
19          public static readonly ILog ATSAdminLog = LogManager.GetLogger("AnywhereTS.ATSAmdin");          public static readonly ILog ATSAdminLog = LogManager.GetLogger("AnywhereTS.ATSAmdin");
20          public static readonly ILog TSControlPanelLog = LogManager.GetLogger("AnywhereTS.TSControlPanel");          public static readonly ILog TSControlPanelLog = LogManager.GetLogger("AnywhereTS.TSControlPanel");
21            public static readonly ILog DatabaseLog = LogManager.GetLogger("AnywhereTS.DBSupport");
22    
23            public static readonly ILog ATSAdminInstallerLog = LogManager.GetLogger("AnywhereTS.ATSAmdin.Installer");
24            public static readonly ILog TSControlPanelInstallerLog = LogManager.GetLogger("AnywhereTS.TSControlPanel.Installer");
25            #endregion
26    
27            #region log4net help
28            public static List<string> GetMessagesFromThreadContextStack(string RawContextStack)
29            {
30                try
31                {
32                    ThreadContextStack tc = ThreadContext.Stacks[RawContextStack.ToUpper()];
33                    if (tc == null) { return new List<string>(); }
34                    else { return GetMessagesFromThreadContextStack(tc); }
35                }
36                catch { return new List<string>(); }
37            }
38            public static List<string> GetMessagesFromThreadContextStack(ThreadContextStack rawTCS)
39            {
40                Type t = typeof(ThreadContextStack);
41                //ConstructorInfo ci = t.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[0], null);
42                //ThreadContextStack tmpRawTCS = null;
43                //tmpRawTCS = (ThreadContextStack)ci.Invoke(null);
44                List<string> stObjects = new List<string>();
45                ThreadContextStack context = (rawTCS as ThreadContextStack);
46                for (int i = 0; i < context.Count; i++)
47                {
48                    MethodInfo mi = t.GetMethod("GetFullMessage", BindingFlags.NonPublic | BindingFlags.Instance);
49                    string message = mi.Invoke(context, null).ToString();
50                    stObjects.Add(message);
51                    context.Pop();
52                }
53                stObjects.Reverse();
54                rawTCS.Clear();
55                // push the popped Context message back onto the original ContextStack
56                foreach (string stObject in stObjects) { rawTCS.Push(stObject); }
57                return stObjects;
58            }
59          #endregion          #endregion
60      }      }
61  }  }

Legend:
Removed from v.48  
changed lines
  Added in v.147

  ViewVC Help
Powered by ViewVC 1.1.22