private static void RegisterLogger(Container container) { var configPath = Path.Combine(Directory.GetCurrentDirectory(), NLogConfigName); var logFactory = new NLoggerFactory(configPath); container.RegisterInstance <ILoggerFactory>(logFactory); container.Register(() => logFactory.CreateLogger(LogNames.MainLog)); }
public static void Init(TestContext context) { //CleanUp нельзя делать, нужно самому смотреть, что все ок. CleanUp(); var factory = new NLoggerFactory("NLog.config"); _logger = factory.CreateLogger("main"); }
public void OperateLogToDbTest() { var testModel = new TestModel { Id = Guid.NewGuid(), TestTitle = "测试操作日志", TestNumber = 2, TestDateTime = DateTime.Now }; logFactory = new NLoggerFactory(); //创建日志对象 log = logFactory.CreateLogger("operateLog"); //日志数据赋值 var actionLog = new OperateLog() { Id = Guid.NewGuid(), Ip = "127.0.0.1", OperatorId = Guid.NewGuid().ToString(), OperAccount = "Account1", OperBranch = "运营1", OperType = OperatorType.Member, OperRemark = "操作备注", MemberId = Guid.NewGuid().ToString(), OriginalValue = JsonUtil.Serialize(new { Model = typeof(TestModel).Name, EntityId = testModel.Id, Title = testModel.TestTitle, 价格 = 99.0 }), ModifiedValue = JsonUtil.Serialize(new { Title = testModel.TestTitle + "修改后", 价格 = 59.0 }), ModelType = typeof(TestModel).FullName, Action = HandleActionType.Modify, SubAction = SubHandleActionType.None, Business = "订单模块", Remark = "这是备注说明", CreateTime = DateTime.Now }; //插入数据库 log.LogData(actionLog); Thread.Sleep(2000); }
public BasicTest() { logFactory = new NLoggerFactory(); log = logFactory.CreateLogger <BasicTest>(); }