コード例 #1
0
    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();
    }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: kbabiy/LogCast
        static void Main()
        {
            LogConfig.Configure(new NLogManager());

            Operation();

            //Let the logs sending complete
            LogManager.Flush(TimeSpan.FromMinutes(1));
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        static void Main()
        {
            //Configuring from App.config
            LogConfig.Configure(new DirectLogManager());

            Operation();

            //Let the logs sending complete
            LogManager.Flush(TimeSpan.FromMinutes(1));
        }
コード例 #6
0
 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();
 }
コード例 #7
0
        // 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);
        }
コード例 #8
0
        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));
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: kbabiy/LogCast
        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));
        }
コード例 #10
0
        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));
            }
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        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");
        }
コード例 #13
0
        /// <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();
        }
コード例 #14
0
 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;
     }
 }
コード例 #15
0
 public Startup(IConfiguration configuration)
 {
     LogConfig.Configure();
     Configuration = configuration;
 }
コード例 #16
0
 public override void Act()
 {
     LogConfig.Configure(_managerMock.Object);
     base.Act();
 }