//public static void Log(string message, EditionEntity edition, LoggingEventType logLevel) //{ // message += " EventId=" + edition.EventId + ", EditionId=" + edition.EditionId; // var logger = new Log4NetAdapter(LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); // logger.Log(new LogEntry(logLevel, message)); //} public static void Log(LogEntity log, LoggingEventType logLevel) { var message = JsonConvert.SerializeObject(log); var logger = new Log4NetAdapter(LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); logger.Log(new LogEntry(logLevel, message)); }
static void Main(string[] args) { var logger = new Log4NetAdapter(Utils.GetDefaultConfigFile()); var application = new WatchdogTrayApplication(logger); application.Run(); }
public MainWindow() { InitializeComponent(); // Test ILog log = LogManager.GetLogger("hibernating"); ILogger nlogAdapter = new Log4NetAdapter(log); var hibernateOutput = Hibernate.TestApp.Main(); log.Debug(hibernateOutput); }
public ILogger CreateLogger(string name) { if (_loggers.ContainsKey(name)) { return(_loggers[name]); } else { ILogger logger = new Log4NetAdapter(name); _loggers.Add(name, logger); return(logger); } }
public ILogger CreateLogger(string name) { if (!_loggers.ContainsKey(name)) { lock (_loggers) { // Have to check again since another thread may have gotten the lock first if (!_loggers.ContainsKey(name)) { _loggers[name] = new Log4NetAdapter(name); } } } return(_loggers[name]); }
public ILogger CreateLogger(string name) { if (!_loggers.ContainsKey(name)) { lock (_loggers) { // Have to check again since another thread may have gotten the lock first if (!_loggers.ContainsKey(name)) { _loggers[name] = new Log4NetAdapter(name); } } } return _loggers[name]; }
public void TestFindById() { IApplicationSettings applicationSettings = new AppConfigApplicationSettings(); ApplicationSettingsFactory.InitializeApplicationSettingsFactory(applicationSettings); log4net.Config.XmlConfigurator.Configure(); ILogger logger = new Log4NetAdapter(); LoggingFactory.InitializeLogFactory(logger); AdoUnitOfWork unitOfWork = new AdoUnitOfWork(); DataPointRepository dataPointRepository = new DataPointRepository(unitOfWork); dataPointRepository.FindBy(1); }
/// <summary> /// 初始化日志系统 /// </summary> private void InitializeLogger() { try { //log4net.Config.XmlConfigurator.Configure(); string log4NetConfigPath = ApplicationSettingsFactory.GetApplicationSettings().Log4NetConfigPath; FileInfo fileInfo = new FileInfo(log4NetConfigPath); XmlConfigurator.ConfigureAndWatch(fileInfo); ILogger logger = new Log4NetAdapter();//IocContainerFactory.GetUnityContainer().Resolve<ILogger>(); LoggingFactory.InitializeLogFactory(logger); } catch (Exception e) { string message = DateTime.Now.ToString() + "调用InitializeLogger初始化日志系统失败!异常信息如下 :" + e.Message; string logFilePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"Log/BootStrapperLog.txt"); System.IO.File.WriteAllText(logFilePath, message); } }
public ILogger GetLogger() { Log4NetAdapter adapter = null; switch (LoggingSettings.Settings.Target) { case LoggingTarget.FileSystem: { adapter = new Log4NetAdapter(EnviromnentHelper.IsLoggingEnabled, LoggingSettings.Settings.EnableEncryption, LoggingSettings.Settings.FileName); break; } case LoggingTarget.Database: { adapter = new Log4NetAdapter(EnviromnentHelper.IsLoggingEnabled, LoggingSettings.Settings.EnableEncryption, LoggingSettings.Settings.ConnectionString, LoggingSettings.Settings.Command); break; } } return(adapter); }
public static void Log(string message, LoggingEventType logLevel) { var logger = new Log4NetAdapter(LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); logger.Log(new LogEntry(logLevel, message)); }