Inheritance: IOptions
Beispiel #1
0
        static void Main(string[] args)
        {
            string pwd = Directory.GetCurrentDirectory();
            string dbName = "LoggerTest";
            CreateSqlDatabase(pwd, dbName);
            string connectionString =
                string.Format(@"Data Source=(LocalDb)\v11.0;Initial Catalog={0};AttachDBFilename={1}\{2}.mdf"
                , dbName, pwd, dbName);

            IOptions options = new Options(connectionString, dbName + ".dbo.LogOptions", OptionsReaderType.Database);
            options["LogWriteTarget"] = "Database";
            options["LogConnectionString"] = connectionString;
            options["LogWriteTable"] = dbName + ".dbo.LogOutput";
            options["LogDaysToKeep"] = "1";
            LogAccess.Init(options);
            options.Save();

            var logger = LogAccess.GetLogger("alogger");
            for (int n = 0; n < 30; n++)
            {
                try
                {
                    Console.Write(submain(0));
                }
                catch (Exception ex)
                {
                    logger.Error("happy error", ex);
                }
            }
            for (int n = 0; n < 10000; n++)
            {
                logger.Info("info" + n, new int[] { n, 2, 3 });
            }
            Console.ReadKey();
        }
 public void GetWriterTest()
 {
     IOptions options = new Options("","Log");
      LogWriterFactory target = new LogWriterFactory(options);
      ILogWriter actual;
      actual = target.GetWriter();
      Assert.IsNotNull(actual);
 }