예제 #1
0
파일: TestBase.cs 프로젝트: salty/SmplLog
        public LogEvent GetLogEvent()
        {
            LogEvent logEvent = new LogEvent();
              logEvent.Message = logEventMessage;
              logEvent.Occurred = logEventOccurred;
              logEvent.LogEventLevel = logEventLevel;
              logEvent.Data = string.Empty;

              return logEvent;
        }
예제 #2
0
파일: Logger.cs 프로젝트: salty/SmplLog
        /// <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);
        }