Esempio n. 1
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));
        }
Esempio n. 2
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);
        }