public void Initialize() { Common.Logic.AppConfig.InitContext(true); Log4NetConfig.ConfigureFile(); //初始化默认打开 PlotRun(); }
public void test() { Log4NetConfig.Configure(); try { var mpaccounts = StaticObjects.wechatdh.ExecuteTable("select ID,Name from MpAccount where IsDelete=0 and isnull(AutoSyncUser,0)=1").AsEnumerable().Select(c => new { ID = DbTool.ToString(c["ID"]), Name = DbTool.ToString(c["Name"]), }); foreach (var mp in mpaccounts) { try { LogWriter.Info(string.Format("同步公众号{0}[{1}]的分组开始", mp.Name, mp.ID)); RefreshGroup(mp.ID); LogWriter.Info(string.Format("同步公众号{0}[{1}]的分组结束", mp.Name, mp.ID)); LogWriter.Info(string.Format("同步公众号{0}[{1}]的用户开始", mp.Name, mp.ID)); ReFreshFans(mp.ID); LogWriter.Info(string.Format("同步公众号{0}[{1}]的用户结束", mp.Name, mp.ID)); } catch (Exception ex) { LogWriter.Error(ex, string.Format("同步公众号{0}[{1}]的分组和用户出现错误", mp.Name, mp.ID)); } } } catch (Exception ex) { LogWriter.Error(ex, "同步微信分组和用户出现错误"); throw ex; } }
/// <summary> /// Processes the selected Log4Net Config File and attempts to load it. /// </summary> /// <param name="selectedFileName"></param> private void ProcessSelectedLog4NetConfigFile(string selectedFileName) { Log4NetConfigFileSuccessfullyLoaded = false; try { Log4NetConfig = Log4NetConfigLoader.CreateLog4NetConfig(selectedFileName); } catch (InvalidLog4NetConfigAttributeValueException e) { ShowErrorMessage("An error occured processing a value within the file.", "File Content Error", e); } catch (InvalidLog4NetConfigStructureException e) { ShowErrorMessage("An error occured while reading from the selected file.", "File Structure Error", e); } catch (Log4NetConfigFileAccessErrorException e) { ShowErrorMessage("An error occured while attempting to access the selected file.", "File Access Error", e); } catch (Exception e) { ShowErrorMessage("An unknown error occured while attempting to process the selected file.", "Unknown Error", e); } Log4NetConfigFileSuccessfullyLoaded = true; }
static void Main() { Log4NetConfig.ConfigureFile(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); Log4NetConfig.Configure(); }
public void Start() { Log4NetConfig.Init(true); Log.Assign(new Log4NetLog(LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType))); this.bus = ServiceBus .Create(c => c.AddEnryptionAlgorithm(new TripleDesEncryptionAlgorithm()) .AddCompressionAlgorithm(new DeflateCompressionAlgorithm())) .Start(); }
/// <summary> /// Opens a text file dialog and returns the selected file location. /// </summary> private void SelectTextFileToOpen() { _log4NetConfig = null; Log4NetOpenFileDialog log4NetOpenFileDialog = new Log4NetOpenFileDialog(); log4NetOpenFileDialog.ShowDialog(); if (log4NetOpenFileDialog.Log4NetConfigFileSuccessfullyLoaded) { _log4NetConfig = log4NetOpenFileDialog.Log4NetConfig; } }
public void Execute(IJobExecutionContext context) { Log4NetConfig.Configure(); try { Start(); } catch (Exception e) { LogWriter.Info(string.Format("同步程序异常:{0},错误:{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), e.Message)); LogWriter.Error(e, e.Message); } }
protected void Application_Start() { if (ConfigurationManager.AppSettings["CreateDatabase"] == "1") { InitializeDatabase(); } AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); Log4NetConfig.Configure(Server); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); //依赖注入 AutofacConfig.Register(); //注册logNet配置 Log4NetConfig.LogConfig(); //注册过滤器 FilterConfig.RegisterFilters(GlobalFilters.Filters); //实体模型映射 Mapper.Initialize(x => { x.AddProfile <SourceProfile>(); }); }
/// <summary> /// Starts the application /// </summary> public static void Start() { FormulaHelper.RegisterService <IUserService, UserService>(); FormulaHelper.RegisterService <IOrgService, OrgService>(); FormulaHelper.RegisterService <IRoleService, RoleService>(); FormulaHelper.RegisterService <IEnumService, EnumService>(); FormulaHelper.RegisterService <IResService, ResService>(); FormulaHelper.RegisterService <IMessageService, MessageService>(); FormulaHelper.RegisterService <IWorkflowService, WorkflowService>(); FormulaHelper.RegisterService <IDataLogService, DataLogService>(); FormulaHelper.RegisterService <ICalendarService, CalendarService>(); // 配置Log4net Log4NetConfig.Configure(); Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(Formula.HttpModule.ScriptModule)); }
/// <summary> /// 向服务器发送get请求 返回服务器回复数据 /// </summary> /// <param name="CookiesContainer"></param> /// <param name="url"></param> /// <returns></returns> public static byte[] SendGetRequest(ref CookieContainer CookiesContainer, string url) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "get"; request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"; request.Headers.Add("Accept-Language", "zh-cn,en-us;q=0.8,zh-hk;q=0.6,ja;q=0.4,zh;q=0.2"); request.Referer = "https://wx.qq.com/"; if (CookiesContainer == null) { CookiesContainer = new CookieContainer(); } request.CookieContainer = CookiesContainer; //启用cookie HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream response_stream = response.GetResponseStream(); int count = (int)response.ContentLength; int offset = 0; byte[] buf = new byte[count]; while (count > 0) //读取返回数据 { int n = response_stream.Read(buf, offset, count); if (n == 0) { break; } count -= n; offset += n; } return(buf); } catch (Exception ex) { Log4NetConfig.Configure(); LogWriter.Error(ex, string.Format("url:{0}", url)); return(null); } }
private void AutoForm_Load(object sender, EventArgs e) { Log4NetConfig.Configure(); UpdateAccessToken(); int.TryParse(System.Configuration.ConfigurationManager.AppSettings["ConfigUpdateTime"], out ConfigUpdateTime); Thread th1 = new Thread(CheckConfig); th1.Start(); Thread th2 = new Thread(CheckReply); th2.Start(); Thread th3 = new Thread(CheckLogin); th3.Start(); Thread th4 = new Thread(CheckFriends); th4.Start(); Thread th5 = new Thread(UpdateShowStatus); th5.Start(); }
//If you need to support more log4net configuration, simply add them to this class and the Log4Net config entries in appSettings public static void LoadConfig(Assembly assembly, Log4NetConfig config) { var hierarchy = (Hierarchy)LogManager.GetRepository(assembly); hierarchy.Root.RemoveAllAppenders(); foreach (var appender in config.Appenders) { if (appender.AppenderType == AppenderTypes.Console) { hierarchy.Root.AddAppender(LoadConsoleAppender(appender)); } else if (appender.AppenderType == AppenderTypes.RollingFile) { hierarchy.Root.AddAppender(LoadRollingFileAppender(appender)); } } hierarchy.Root.Level = GetLevel(config.Level); hierarchy.Configured = true; }
static void Main(string[] args) { Log4NetConfig.Configure(); init(); var timeoutAlarm_instance = new WorkflowScheduleJob.TimeoutAlarmJob(); timeoutAlarm_instance.Execute(new VirJobExecutionContext()); var timeoutAutoPass_instance = new WorkflowScheduleJob.TimeoutAutoPassJob(); timeoutAutoPass_instance.Execute(new VirJobExecutionContext()); var timeoutDeadline_instance = new WorkflowScheduleJob.TimeoutDeadlineJob(); timeoutDeadline_instance.Execute(new VirJobExecutionContext()); var timeoutNotice_instance = new WorkflowScheduleJob.TimeoutNoticeJob(); timeoutNotice_instance.Execute(new VirJobExecutionContext()); var calendarService = FormulaHelper.GetService <ICalendarService>(); calendarService.SetHolidayNULL(); }
public void Configuration(IAppBuilder app) { var config = new HttpConfiguration(); var builder = new ContainerBuilder(); AutofacConfig.RegisterAutofacIoc(app, config, builder); AuthConfig.ConfigureOAuth(app); AutoMapperConfig.RegisterMapping(); ContextConfig.RegisterContext(builder); LogicConfig.RegisterContext(builder); ApiHelperConfig.RegisterContext(builder); Log4NetConfig.RegisterLogger(builder); FluentValidationConfig.RegisterValidation(builder, config); var container = builder.Build(); config.DependencyResolver = new AutofacWebApiDependencyResolver(container); WebApiConfig.Register(config); XmlConfigurator.Configure(); builder.RegisterWebApiFilterProvider(GlobalConfiguration.Configuration); app.UseAutofacMiddleware(container); app.UseAutofacWebApi(config); app.UseWebApi(config); //app.UseCors(CorsOptions.AllowAll); }
static void Main(string[] args) { Log4NetConfig.Configure(); var init = new SzsowData(); string step = string.Format("初始化用户开始:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); LogWriter.Info(step); Console.WriteLine(step); init.InitUser(); step = string.Format("初始化用户结束:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); LogWriter.Info(step); Console.WriteLine(step); Console.ReadKey(); return; step = string.Format("初始化项目开始:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); LogWriter.Info(step); Console.WriteLine(step); init.InitProject(); step = string.Format("初始化项目结束:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); LogWriter.Info(step); Console.WriteLine(step); Console.ReadKey(); }
static Bootstrapper() { Log4NetConfig.Execute(); }
public Startup(IConfiguration configuration) { Configuration = configuration; Log4NetConfig.Init(configuration); }
private void button1_Click(object sender, EventArgs e) { Log4NetConfig.Configure(); var numberlength = this.textBox1.Text; var letterlength = this.textBox2.Text; var pinyinlength = this.textBox3.Text; var sleeptime = this.textBox4.Text; int nl = 0, ll = 0, pl = 0, st = 0; if (!int.TryParse(numberlength, out nl)) { MessageBox.Show("数字域名长度有误"); return; } if (nl < 0 || nl > 6) { MessageBox.Show("数字域名长度必须是0到6"); return; } if (!int.TryParse(letterlength, out ll)) { MessageBox.Show("字母域名长度有误"); return; } if (ll < 0 || ll > 6) { MessageBox.Show("字母域名长度必须是0到6"); return; } if (!int.TryParse(pinyinlength, out pl)) { MessageBox.Show("拼音域名长度有误"); return; } if (pl < 0 || pl > 2) { MessageBox.Show("拼音域名长度必须是0到2"); return; } if (!int.TryParse(sleeptime, out st)) { MessageBox.Show("查询间隔有误"); return; } if (st < 1) { MessageBox.Show("拼音域名长度必须大于1"); return; } List <string> dn = null; if (this.listBoxDomain.SelectedItems.Count > 0) { dn = new List <string>(); foreach (var item in this.listBoxDomain.SelectedItems) { dn.Add(item.ToString()); } domainext = dn.ToArray(); } this.button1.Enabled = false; toolStripStatusLabel1.Text = "数据正在初始化"; CallBackDelegate cbd = Callback; tcd = new ThreadingCheckDomain(st, nl, ll, pl, domainext, this.textBoxPre.Text, this.textBoxSuf.Text); Thread th = new Thread(tcd.Start); th.Start(cbd); }
private void ConfigureLog() { Log4NetConfig.Configure(); }
//private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) //{ // // Log4Net.Error(e.ExceptionObject); // NLog.Error(e.ExceptionObject); //} private static void Main(string[] args) { // Log4net // Init - in AssemblyInfo.cs // [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)] // Load log4net configuration XmlConfigurator.Configure(); // Check valid log4net configuration Log4NetConfig.Verify(); // Unhandled exceptions //AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // NLog - Logging to log and raygun.io NLog.Trace("NLog Sample trace message"); NLog.Debug("NLog Sample debug message"); NLog.Info("NLog Sample informational message"); NLog.Warn("NLog Sample warning message"); NLog.Error("NLog Sample error message"); NLog.Fatal("NLog Sample fatal error message"); // Log4Net - Logging to log and raygun.io Log4Net.Debug("Log4Net Sample debug message"); Log4Net.Info("Log4Net Sample informational message"); Log4Net.Warn("Log4Net Sample warning message"); Log4Net.Error("Log4Net Sample error message"); Log4Net.Fatal("Log4Net Sample fatal error message"); // alternatively you can call the Log() method // and pass log level as the parameter. NLog.Log(LogLevel.Info, "Sample informational message"); // Throw exception try { throw new Exception("Test Exception"); } catch (Exception ex) { NLog.Error(ex); } // IoC var kernel = new StandardKernel(new NinjectDep()); var service = kernel.Get <Service <Person> >(); service.AddItem(new Person { Age = 21, Name = "John" }); try { // This should throw an error service.AddItem((Person)(new Employee { EmployeeId = 33, Name = "Bill" } as IEntity)); } catch (Exception ex) { NLog.Error(ex); } service.DisplayItems(); Console.WriteLine("Finished..."); Console.Read(); }
public PDFToSWFAndSnap() { AppConfig.InitContext(); Log4NetConfig.ConfigureFile(); }
public LoggingFacade(Log4NetConfig config) { LogManagerExtensions.LoadConfig(Assembly.GetEntryAssembly(), config); }
static Bootstrapper() { Log4NetConfig.Execute(); EnsureApplication(); }
public Startup(IConfiguration configuration) { Configuration = configuration; Log4NetConfig.Init(Configuration);//加载log4net }