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

Annotation of /trunk/AnywhereTS.Logging/Logging.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 147 - (hide annotations) (download)
Sun Jul 15 08:43:40 2012 UTC (8 years, 11 months ago) by william
File size: 2679 byte(s)
+ add installer logging entries

1 william 36 using System;
2     using System.Collections.Generic;
3     using System.Text;
4     using log4net.Config;
5     using log4net;
6     using System.IO;
7 william 70 using log4net.Util;
8     using System.Reflection;
9     using System.Collections;
10 william 36
11     namespace AnywhereTS
12     {
13     public static class Logging
14     {
15     static Logging() { Logging.Initialize(); }
16 william 106 private static void Initialize() { XmlConfigurator.Configure(new FileInfo("AnywhereTS.Logging.dll.config")); }
17 william 36
18     #region Log access
19     public static readonly ILog ATSAdminLog = LogManager.GetLogger("AnywhereTS.ATSAmdin");
20 william 48 public static readonly ILog TSControlPanelLog = LogManager.GetLogger("AnywhereTS.TSControlPanel");
21 william 86 public static readonly ILog DatabaseLog = LogManager.GetLogger("AnywhereTS.DBSupport");
22 william 147
23     public static readonly ILog ATSAdminInstallerLog = LogManager.GetLogger("AnywhereTS.ATSAmdin.Installer");
24     public static readonly ILog TSControlPanelInstallerLog = LogManager.GetLogger("AnywhereTS.TSControlPanel.Installer");
25 william 36 #endregion
26 william 70
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 william 71 catch { return new List<string>(); }
37 william 70 }
38     public static List<string> GetMessagesFromThreadContextStack(ThreadContextStack rawTCS)
39     {
40 william 71 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 william 70 }
59     #endregion
60 william 36 }
61     }

  ViewVC Help
Powered by ViewVC 1.1.22