Пример #1
0
        public LogEvent GetLogEvent()
        {
            LogEvent logEvent = new LogEvent();
              logEvent.Message = logEventMessage;
              logEvent.Occurred = logEventOccurred;
              logEvent.LogEventLevel = logEventLevel;
              logEvent.Data = string.Empty;

              return logEvent;
        }
Пример #2
0
        /// <summary>
        /// Create and return a LogEvent
        /// </summary>
        /// <param name="message">The message to be output</param>
        /// <param name="occurred">The DateTime when the event occurred</param>
        /// <param name="level">The level specified for the event</param>
        /// <returns></returns>
        public virtual LogEvent GetLogEvent(
            string message,
            DateTime occurred,
            EventLevel level,
            string location)
        {
            LogEvent logEvent = new LogEvent();
              logEvent.Message = message;
              logEvent.Occurred = occurred;
              logEvent.LogEventLevel = level;
              logEvent.Location = location;

              return logEvent;
        }
Пример #3
0
        public void MinimalLockPreventFileIOExceptionsWithMultipleAppenders()
        {
            string filePath = ConfigurationManager.AppSettings["FileAppenderTestTempPath"];

              string logFilePath = filePath + "\\log-mnultiple.txt";

              Trace.WriteLine("Logfilepath is " + logFilePath);

              if (File.Exists(logFilePath))
            File.Delete(logFilePath);

              FileAppender fileAppender = new FileAppender(logFilePath, "FileAppender1");
              FileAppender fileAppender2 = new FileAppender(logFilePath, "FileAppender2");

              LogEvent logEvent = new LogEvent();
              logEvent.Message = "Hello!";

              //fileAppender.AppenderLockMode = FileAppender.LockMode.MinimalLock;
              //fileAppender2.AppenderLockMode = FileAppender.LockMode.MinimalLock;

              for (int i = 0; i < 1000; i++)
              {
            fileAppender.WriteLogEvent(null, logEvent);
            fileAppender2.WriteLogEvent(null, logEvent);
              }

              Assert.IsTrue(File.Exists(logFilePath));
        }
Пример #4
0
        public void FileAppenderCreatesFileIfNotExists()
        {
            string filePath = ConfigurationManager.AppSettings["FileAppenderTestTempPath"] + "log.txt";

              FileAppender fileAppender = new FileAppender(filePath, "FileAppender1");

              LogEvent logEvent = new LogEvent();
              logEvent.Message = "Hello!";
              fileAppender.WriteLogEvent(null, logEvent);

              Assert.IsTrue(File.Exists(filePath), "Path was " + filePath);
        }