Esempio n. 1
0
        public static void TestTrace()
        {
            FileLog backupFileLog = new FileLog("TestBackupLog", "", enumEventPriority.All);

            LoggingMgr lm = new LoggingMgr(
                new List <ILoggingTarget>()
            {
                new WindowsEventLog("Application", "LoggingTest", backupFileLog, enumEventPriority.Critical),
            }, backupFileLog, enumTraceLevel.All);

            TraceLog log = new TraceLog();

            lm.TraceToWindow = true;

            int n = 0;

            while (true)
            {
                using (new LoggingContext("Running Trace Test"))
                {
                    lm.Trace(@"Number: " + n.ToString());
                    n++;

                    LoggingTest.TraceDeep1(lm);

                    LoggingTest.TraceLargeMessage(lm);

                    System.Threading.Thread.Sleep(1);
                }
            }
        }
Esempio n. 2
0
 protected static void TraceDeep3(LoggingMgr lm)
 {
     using (new LoggingContext("TraceDeep3"))
     {
         System.Threading.Thread.Sleep(10);
         lm.Trace("Call To TraceDeep3.");
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Main Window for Application
        /// </summary>
        public MainWindow()
        {
            try
            {
                InitializeComponent();
                _configSettings           = LoadConfigurationSettings();
                _loggingMgr               = new LoggingMgr(_loggingKey);
                _loggingMgr.TraceToWindow = true;
                _daMgr = new DataAccessMgr(_connectionKey, _loggingMgr);

                // This host requires an app session object
                _appSession = new AppSession(_daMgr
                                             , _engineId
                                             , _assemblyVersion
                                             , _assemblyName
                                             , Status);

                // create paging manager for task processing queue
                PagingMgr tpq = new PagingMgr(_daMgr
                                              , string.Format("{0}.{1}", DataAccess.Constants.SCHEMA_CORE, TaskProcessing.Constants.TaskProcessingQueue)
                                              , null, 1, null);

                // pass paging manager to paging controll
                pagingTableTPQ.Source = tpq;
                pagingTableTPQ.Title  = "Task Processing Queue";

                // set the status control for the local TPE
                localTpeStatus.SetContext(this, null, OnPlusMinusClick);
                // pass in the configuration settings
                localTpeStatus.Display(TraceLevelChanged
                                       , MaxTasksChanged
                                       , _connectionKey
                                       , _loggingKey
                                       , _configId
                                       , _engineId
                                       , _taskAssemblyPath
                                       , _hostEndpointAddress
                                       , _maxTasks
                                       , _loggingMgr.TraceLevel);

                // right now we cannot connect to any remote host
                remoteTpeStatus.IsEnabled = false;
            }
            catch (Exception e)
            {
                string errorFileName = "TaskProcessingEngine.Exception.txt";
                string msg           = "Will attempt to write exception details to file: " + errorFileName
                                       + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine;
                MessageBox.Show(msg, "Fatal Error - Look for file: " + errorFileName);
                FileManagement.FileMgr.WriteTextToFile(errorFileName, msg, false, true);
                Exit();
            }
        }
Esempio n. 4
0
 private static void HandleException(Exception e)
 {
     try
     {
         LoggingMgr loggingMgr = new LoggingMgr(AppConfigMgr.GetValue(Configuration.Constants.LoggingKey).ToString());
         loggingMgr.WriteToLog(e, enumEventPriority.Critical);
     }
     finally
     {
         string errorFileName = "DbSetupMgr.Exception.txt";
         string msg           = "Will attempt to write exception details to file: " + errorFileName
                                + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine;
         MessageBox.Show(msg, "Fatal Error - Look for file: " + errorFileName);
         FileManagement.FileMgr.WriteTextToFile(errorFileName, msg, false, true);
     }
 }
Esempio n. 5
0
        public static void RunTest()
        {
            // Uncomment the MSMQLog line out if you have MSMQ setup with a private queue called NOC
            // MemFileLogTest();

            FileLog backupFileLog = new FileLog("TestBackupLog", "", enumEventPriority.All);

            LoggingMgr lm = new LoggingMgr(
                new List <ILoggingTarget>()
            {
                new WindowsEventLog("Application", "LoggingTest", backupFileLog, enumEventPriority.Critical),
                new FileLog("ApplicationLogFile", Environment.CurrentDirectory, enumEventPriority.All),
                //new FastFileLog( "FastLogFile_" + Process.GetCurrentProcess().Id.ToString(),
                new MemoryFileLog("LoggingTestLog", "LogFile",
                                  Environment.CurrentDirectory, 10000, enumEventPriority.All)
                //new MSMQLog( "MSMQLog", ".\\Private$\\NOC", backupFileLog, enumEventPriority.Critical,
                //        enumEventPriority.Normal)
            }
                , backupFileLog, enumTraceLevel.All);

            //This should log in the Windows Event Log and the file log at c:\applicationLogFile_*.txt
            lm.WriteToLog("Test Log 1: Critical", System.Diagnostics.EventLogEntryType.Information,
                          enumEventPriority.Critical);

            //This should log only in the file log at c:\applicationLogFile_*.txt
            lm.WriteToLog("Test Log 2: Normal", System.Diagnostics.EventLogEntryType.Information,
                          enumEventPriority.Normal);

            // Should only go in FileLog at c:\applicationLogFile_*.txt
            lm.Trace("Trace Token");

            // You can also construct the LoggingMgr with the following constructor. This will give you a default of
            //  windows event logging with a backup text file
            LoggingMgr lmDefault = new LoggingMgr("Application", "LoggingTest", "c:", enumTraceLevel.All);

            lmDefault.WriteToLog("Test Default Log", EventLogEntryType.Information, enumEventPriority.Normal);
        }
Esempio n. 6
0
 protected static void TraceLargeMessage(LoggingMgr lm)
 {
     lm.Trace("RANDOM MESSAGE: ".PadRight(_random.Next(50, 200), (char)_random.Next(65, 90)));
 }