/[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 147 by william, Sun Jul 15 08:43:40 2012 UTC revision 149 by william, Sun Jul 15 11:21:36 2012 UTC
# Line 7  using System.IO; Line 7  using System.IO;
7  using log4net.Util;  using log4net.Util;
8  using System.Reflection;  using System.Reflection;
9  using System.Collections;  using System.Collections;
10    using System.Windows.Forms;
11    using log4net.Appender;
12    using System.Linq;
13    
14  namespace AnywhereTS  namespace AnywhereTS
15  {  {
16      public static class Logging      public static class Logging
17      {      {
18          static Logging() { Logging.Initialize(); }          static Logging() { Logging.Initialize(); }
19          private static void Initialize() { XmlConfigurator.Configure(new FileInfo("AnywhereTS.Logging.dll.config")); }          private static void Initialize()
20            {
21                string path = typeof(Logging).Assembly.Location.ToLower().Replace(@"\AnywhereTS.Logging.dll".ToLower(), "");
22    
23                string config = string.Format(@"{0}\{1}", path, "AnywhereTS.Logging.dll.config");
24                //MessageBox.Show(config);
25                FileInfo fi = new FileInfo(config);
26    
27                if (!fi.Exists)
28                {
29                    MessageBox.Show(string.Format("Logging Config does not exist!{0}{1}", System.Environment.NewLine, fi.FullName));
30                }
31                else
32                {
33                    XmlConfigurator.Configure(new FileInfo(config));
34                }
35            }
36    
37          #region Log access          #region Log access
38          public static readonly ILog ATSAdminLog = LogManager.GetLogger("AnywhereTS.ATSAmdin");          public static readonly ILog ATSAdminLog = LogManager.GetLogger("AnywhereTS.ATSAmdin");
39          public static readonly ILog TSControlPanelLog = LogManager.GetLogger("AnywhereTS.TSControlPanel");          public static readonly ILog TSControlPanelLog = LogManager.GetLogger("AnywhereTS.TSControlPanel");
40          public static readonly ILog DatabaseLog = LogManager.GetLogger("AnywhereTS.DBSupport");          public static readonly ILog DatabaseLog = LogManager.GetLogger("AnywhereTS.DBSupport");
41    
42          public static readonly ILog ATSAdminInstallerLog = LogManager.GetLogger("AnywhereTS.ATSAmdin.Installer");          //public static readonly ILog ATSAdminInstallerLog = LogManager.GetLogger("AnywhereTS.ATSAmdin.Installer");
43          public static readonly ILog TSControlPanelInstallerLog = LogManager.GetLogger("AnywhereTS.TSControlPanel.Installer");          //public static readonly ILog TSControlPanelInstallerLog = LogManager.GetLogger("AnywhereTS.TSControlPanel.Installer");
44          #endregion          #endregion
45    
46    
47            public static void SetLogPath(string path)
48            {
49                var fileAppenders = from appender in log4net.LogManager.GetRepository().GetAppenders()
50                                    where appender is FileAppender
51                                    select appender;
52                fileAppenders.Cast<FileAppender>()
53                   .ToList()
54                   .ForEach(
55                       fa =>
56                       {
57                           FileInfo fi = new FileInfo(fa.File);
58                           string file = fi.Name;
59                           fa.File = new FileInfo(string.Format(@"{0}\{1}", path, file)).FullName;
60                           fa.ActivateOptions();
61                       }
62                   );
63            }
64          #region log4net help          #region log4net help
65          public static List<string> GetMessagesFromThreadContextStack(string RawContextStack)          public static List<string> GetMessagesFromThreadContextStack(string RawContextStack)
66          {          {

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

  ViewVC Help
Powered by ViewVC 1.1.22