private static void smethod_0() { LogManager.Configuration = new LoggingConfiguration(); FileTarget fileTarget = new FileTarget("file"); fileTarget.CreateDirs = true; fileTarget.EnableFileDelete = true; fileTarget.ArchiveNumbering = ArchiveNumberingMode.DateAndSequence; fileTarget.MaxArchiveFiles = 10; fileTarget.KeepFileOpen = true; fileTarget.OpenFileCacheTimeout = 30; fileTarget.EnableArchiveFileCompression = true; fileTarget.AutoFlush = true; fileTarget.Encoding = Encoding.UTF8; fileTarget.ArchiveAboveSize = 1073741824L; string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "DOPE", "Logs").Replace("\\", "/").TrimEnd(new char[] { '/' }); if (Directory.Exists(text)) { try { Directory.Delete(text, true); } catch { } } LogConfig.Configure(fileTarget); fileTarget.FileName = text + "/${filedate}/${logcategory}/log-${botid}.txt"; LogManager.Configuration.AddTarget("file", fileTarget); LogManager.ReconfigExistingLoggers(); }
static void Main() { LogConfig.Configure(new TraceLogManager("logger")); Uri baseAddress = new Uri("http://localhost:8080/service1"); using (ServiceHost host = new ServiceHost(typeof(Service1), baseAddress)) { var smb = new ServiceMetadataBehavior { HttpGetEnabled = true, MetadataExporter = { PolicyVersion = PolicyVersion.Policy15 } }; host.Description.Behaviors.Add(smb); host.Description.Behaviors.Add(new LogCastContextBehavior { LogCallerAddress = true, LogRequestHttpData = true }); //LogConfig.Current.Engine.RegisterInspector(new OperationContextInspector()); host.Open(); Console.WriteLine("The service is ready at {0}", baseAddress); Console.WriteLine("Press <Enter> to stop the service."); Console.ReadLine(); host.Close(); } }
static void Main() { LogConfig.Configure(new NLogManager()); Operation(); //Let the logs sending complete LogManager.Flush(TimeSpan.FromMinutes(1)); }
public override void Act() { var mock = new Mock <ILogManager>(MockBehavior.Loose); mock.Setup(x => x.GetLoggerBridge(It.IsAny <string>())).Returns(Mock.Of <ILoggerBridge>); LogConfig.Configure(mock.Object, true); base.Act(); }
static void Main() { //Configuring from App.config LogConfig.Configure(new DirectLogManager()); Operation(); //Let the logs sending complete LogManager.Flush(TimeSpan.FromMinutes(1)); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); LogConfig.Configure(); //GlobalConfiguration.Configure(WebApiConfig.Register); GlobalConfiguration.Configuration.EnsureInitialized(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { //TODO: //if (env.IsDevelopment()) // app.UseDeveloperExceptionPage(); BackgroundServiceConfig.Configure(app, env, loggerFactory, Configuration); DataConfig.Configure(app, env, loggerFactory, Configuration); LogConfig.Configure(app, env, loggerFactory, Configuration); AuthConfig.Configure(app, env, loggerFactory, Configuration); MvcConfig.Configure(app, env, loggerFactory, Configuration); ReportServiceConfig.Configure(app, env, loggerFactory, Configuration); MessageHubConfig.Configure(app, env, loggerFactory, Configuration); }
private void Initialize() { FallbackLogger = CreateFallbackLogger(); Options = LogCastOptions.Parse( Endpoint, Throttling, RetryTimeout, SendingThreadCount, SendTimeout, EnableSelfDiagnostics); _messageRouter = new LogMessageRouter(ParseSkipPercentage(SkipPercentage)); // This case is mostly for scenario when a client uses "real" NLog LogManager // and doesn't use our ILogger/LogManager/LogConfig if (!LogConfig.IsConfigured && !LogConfig.IsInProgress) { LogConfig.Configure(new NLogManager(this)); } }
static void Main() { // Scenario 1: when the listener added to specific trace source and explicit configuration is done (the best!) // Both loggers and "TraceSource" methods are supported LogConfig.Configure(new TraceLogManager(SourceName)); WrappedExample(); //BareLoggerExample(); //BareLoggerUsingObjectModel(); //WrappedExampleWithMultithreadedLogging(); //NestedContextsExample(); //Let the logs sending complete LogManager.Flush(TimeSpan.FromMinutes(1)); }
public LogCastTraceListenerWorker(LogCastTraceListener listener, StringDictionary attributes, IFallbackLogger fallbackLogger) { ParseListenerOptions(attributes); ParseLogCastOptions(attributes); FallbackLogger = fallbackLogger ?? new FileFallbackLogger(FallbackLogDirectory, DaysToKeepFallbackLogs); _messageRouter = new LogMessageRouter(ParseSkipPercentage(SkipPercentage)); // This case is mostly for scenario when a client uses trace methods directly // and doesn't use our ILogger/LogManager/LogConfig if (!LogConfig.IsConfigured && !LogConfig.IsInProgress) { LogConfig.Configure(new TraceLogManager(listener, this)); } }
public static void Register(HttpConfiguration config) { // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( "Default", "{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); LogConfig.Configure(new TraceLogManager("logger")); config.MessageHandlers.Add(new LogCastContextHandler()); config.Services.Add(typeof(IExceptionLogger), new LogCastExceptionLogger()); //LogConfig.BeginConfiguration(new TraceLogManager("logger")) // .WithGlobalInspector(new HttpContextInspector(LoggingOptions.All())) // .End(); }
public void ConfigureServices(IServiceCollection services) { LogConfig.Configure(); services.AddControllers() .AddFluentValidation(s => { s.RegisterValidatorsFromAssemblyContaining <DeveloperValidator>(); s.RunDefaultMvcValidationAfterFluentValidationExecutes = false; }); services.AddSwaggerGen(opt => opt.SwaggerDoc("v1", new OpenApiInfo { Version = "v1" })); services.AddHealthChecks() .AddCheck <HealthCheckExample>("HealthCheckExampleGoogleRequest"); }
/// <summary> /// Specifies how the ASP.NET application will respond to individual HTTP request. /// </summary> /// <param name="app">Instance of <see cref="IAppBuilder"/>.</param> public void Configuration(IAppBuilder app) { LogConfig.Configure(); app.UseRequestLogging(); CorsConfig.ConfigureCors(ConfigurationManager.AppSettings["cors"]); app.UseCors(CorsConfig.Options); HttpConfiguration configuration = new HttpConfiguration(); FormatterConfig.Configure(configuration); RouteConfig.Configure(configuration); ServiceConfig.Configure(configuration); SwaggerConfig.Configure(configuration); app.UseWebApi(configuration); MappingProfile map = new MappingProfile(); map.Iniciar(); }
public bool ProcessRequest(SimpleHttpRequest request, SimpleHttpResponse response) { LogConfig.Configure(); try { return PerformRequest(request, response); } catch (CorruptApplicationDomainException ae) { try { Log.Error(ae); } finally { Environment.Exit(1); } throw; } catch (Exception error) { Log.Error(error); throw; } }
public Startup(IConfiguration configuration) { LogConfig.Configure(); Configuration = configuration; }
public override void Act() { LogConfig.Configure(_managerMock.Object); base.Act(); }