Esempio n. 1
0
        public static void SetupConfigLoggers()
        {
            bool logToFile = Boolean.Parse(ConfigurationManager.AppSettings["logToFile"]);

            if (!logToFile)
            {
                return;
            }

            string sectionName = "loggerSection";

            try
            {
                LoggerSection lSection = (LoggerSection)ConfigurationManager.GetSection(sectionName);

                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);
                    Console.Out.WriteLine(lElement.loggerName);
                }
            } catch (Exception ex) {
                Console.Out.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        static void setupLoggers()
        {
            // normal console writer.
            LoggerSpec outConsole = new LoggerSpec();

            outConsole.name       = LoggerDefine.OUT_CONSOLE;
            outConsole.level      = Logger.Level.Info;
            outConsole.dateFormat = "{0:dd/MM/yyyy H:mm:ss zzz} : ";
            outConsole.logType    = Logger.LogType.Console;
            Logger.Instance.AppendLoggerSpec(outConsole);

            // debug console writer.
            LoggerSpec debugConsole = new LoggerSpec();

            debugConsole.name       = LoggerDefine.DEBUG_CONSOLE;
            debugConsole.level      = Logger.Level.Info;
            debugConsole.dateFormat = "{0:dd/MM/yyyy H:mm:ss zzz} : ";
            debugConsole.logType    = Logger.LogType.Console;
            Logger.Instance.AppendLoggerSpec(debugConsole);
        }