Example #1
0
 /*
 private void InitConsoleTargetAndRule()
 {
     Target target = LogManager.Configuration.AllTargets.FirstOrDefault(x => x.Name == "console");
     LoggingRule rule = new LoggingRule("*", LogLevel.Trace, target);
     LogManager.Configuration.LoggingRules.Add(rule);
 }
  */
 private void LogToConsole(NRLogger.Level level, string message, object[] args = null)
 {
     if ((int)level <= (int)_LogToConsoleLevel)
     {
         var m = (args == null) ? message : string.Format(message, args);
         Console.WriteLine(level.ToString() + " :" + m);
     }
 }
Example #2
0
        private NRLogger.Level _LogToConsoleLevel = NRLogger.Level.Error; // only Errors and Fatal are logged to console

        #endregion Fields

        #region Constructors

        private NRLogger(NRLogger.Level level)
        {
            //PreNLogInit();
            Logger = NLog.LogManager.GetCurrentClassLogger();
            _LogToConsoleLevel = level;
        }
Example #3
0
 public static void Shutdown()
 {
     // NOTE: Can have a race condition on Shutdown as follows:
     //  thread 1: calls ICBCodes.Instance and returns _instance to caller
     //  thread 1: suspended before caller uses returned _instance
     //  thread 2: Shutdown() called which forces _instance to null
     // NB cacheing ICBCodes.Instance in caller is very bad for this
     lock (_syncRoot)
     {
         _instance.Flush();
         _instance = null;
     }
 }
Example #4
0
 public void SetLogToConsoleLevel(NRLogger.Level l)
 {
     _LogToConsoleLevel = l;
 }
Example #5
0
 public static NRLogger Initialise(NRLogger.Level level = NRLogger.Level.Error)
 {
     lock (_syncRoot)
     {
         if (_instance != null)
         {
             throw new Exception("NRLogger.Initialise(..) has already been called");
         }
         _instance = new NRLogger(level);
         return _instance;
     }
 }