예제 #1
0
        public static void SetupConfigLoggers()
        {
            try
            {
                bool logToFile = Boolean.Parse(getAppValue("logToFile"));

                if (!logToFile)
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Message);
                return;
            }

            try
            {
                LoggerSection lSection = (LoggerSection)config.GetSection(ParseConfigManager.LOGGER_SECITON);

                LoggerCollection lCol = lSection.Loggers;
                foreach (LoggerConfigElement lElement in lCol)
                {
                    LoggerSpec logFile = new LoggerSpec();
                    logFile.name       = lElement.loggerName;
                    logFile.level      = Logger.Level.Info;
                    logFile.dateFormat = "{0:dd/MM/yyyy H:mm:ss zzz} : ";
                    logFile.logType    = Logger.LogType.File;
                    logFile.fileName   = Path.Combine(lElement.path, lElement.fileBaseName);
                    Logger.Instance.AppendLoggerSpec(logFile);
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Message);
            }
        }
예제 #2
0
        private static void setupProfileLogger(string loggerToUse)
        {
            LoggerSection lSection = (LoggerSection)config.GetSection(ParseConfigManager.LOGGER_SECITON);

            LoggerCollection lCol = lSection.Loggers;

            foreach (LoggerConfigElement lElement in lCol)
            {
                if (lElement.loggerName != loggerToUse)
                {
                    continue;
                }
                LoggerSpec logFile = new LoggerSpec();
                logFile.name       = lElement.loggerName;
                logFile.level      = Logger.Level.Info;
                logFile.dateFormat = "{0:dd/MM/yyyy H:mm:ss zzz} : ";
                logFile.logType    = Logger.LogType.File;
                logFile.fileName   = Path.Combine(lElement.path, lElement.fileBaseName);
                Logger.Instance.AppendLoggerSpec(logFile);
                return;
            }
            throw new Exception("Logger specified: " + loggerToUse + ", could not be found");
        }