当前位置: 首页>>代码示例>>C#>>正文


C# LoggerConfiguration.Information方法代码示例

本文整理汇总了C#中Serilog.LoggerConfiguration.Information方法的典型用法代码示例。如果您正苦于以下问题:C# LoggerConfiguration.Information方法的具体用法?C# LoggerConfiguration.Information怎么用?C# LoggerConfiguration.Information使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Serilog.LoggerConfiguration的用法示例。


在下文中一共展示了LoggerConfiguration.Information方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public override void Run()
        {
            var cs = CloudConfigurationManager.GetSetting("StorageConnectionString");

            CloudStorageAccount storageAccount;
            CloudStorageAccount.TryParse(cs, out storageAccount);
            var log = new LoggerConfiguration().WriteTo.AzureTableStorage(storageAccount).CreateLogger();

            log.Information("Who let azure out");

            log.Information("Starting processing of messages");

            // Initiates the message pump and callback is invoked for each message that is received, calling close on the client will stop the pump.
            _client.OnMessage((receivedMessage) =>
                {
                    try
                    {
                        // Process the message
                        Trace.WriteLine("Processing Service Bus message: " + receivedMessage.SequenceNumber.ToString());
                    }
                    catch(Exception e)
                    {
                        // Handle any message processing specific exceptions here
                    }
                });

            _completedEvent.WaitOne();
        }
开发者ID:trulstveoy,项目名称:Sandbox,代码行数:28,代码来源:WorkerRole.cs

示例2: Application_Start

        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
              AreaRegistration.RegisterAllAreas();
              GlobalConfiguration.Configure(WebApiConfig.Register);
              RouteConfig.RegisterRoutes(RouteTable.Routes);

            // Apply the HandleException attribute to all MVC controllers.
            // It extends the MVC HandleError attribute so that it catches HTTP errors with status 500 and displays them nicely
            // instead of defaulting to the IIS error page.
            GlobalFilters.Filters.Add(new CustomHandleError());

            // Apply the CustomAuthorize filter to all MVC controllers.
            // It extends the MVC Authorize attribute to take care of role-checking and making sure user accounts have not been disabled.
            // To prevent a controller from needing authentication and authorization (like AccountController), use [AllowAnonymous].
            // To enforce a role on an MVC controller or action, use [CustomAuthorize(Roles = "admin")].
            GlobalFilters.Filters.Add(new CustomAuthorize());

            // Apply the CustomApiAuthorize filter to all API controllers.
            // It extends the API Authorize attribute to take care of role-checking and making sure user accounts have not been disabled.
            // To enforce a role on an API controller or action, use [CustomApiAuthorize(Roles = "admin")].
            GlobalConfiguration.Configuration.Filters.Add(new CustomApiAuthorize());

            // Apply the ValidateApiModel attribute to all API controllers.
            // It extends the ActionFilterAttribute to perform model validation on DTOs that use the System.DataComponents.DataAnnotations annotations.
            // If the model does not validate, it returns a 400 Bad Request with error messages specified in the annotations.
            GlobalConfiguration.Configuration.Filters.Add(new ValidateApiModelAttribute());

            // Serilog.
            using (var log = new LoggerConfiguration().ReadFrom.AppSettings().CreateLogger())
            {
                log.Information("Application_Start: the SLLInvoices application has started");
            }
        }
开发者ID:txsll,项目名称:SLLInvoices,代码行数:34,代码来源:Global.asax.cs

示例3: FinishedLaunching

        //
        // This method is invoked when the application has loaded and is ready to run. In this 
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
			Current = this;

			var log = new LoggerConfiguration().CreateLogger();

			log.Information("Loading");

            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;

            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            // If you have defined a view, add it here:
            // window.RootViewController  = navigationController;

			var rootNavigationController = Utilities.BuildNavigationController();
            rootNavigationController.PushViewController(new ViewControllers.Login(), false);
            window.RootViewController = rootNavigationController;

            // make the window visible
            window.MakeKeyAndVisible();

            Utilities.SetTintColor();

            autoSuspendHelper.FinishedLaunching(app, options);

            return true;
        }
开发者ID:ehill8624,项目名称:ValkreRender,代码行数:36,代码来源:AppDelegate.cs

示例4: Run

 public static void Run()
 {
     var logger = new LoggerConfiguration()
     .WriteTo.MSSqlServer(@"Server=.;Database=LogEvents;Trusted_Connection=True;", "Logs")
     .CreateLogger();
     logger.Information("I am an information log");
     logger.Error("Hello, I am an error log");
 }
开发者ID:andyfengc,项目名称:SerilogTutorial,代码行数:8,代码来源:DatabaseLogger.cs

示例5: Application_End

 void Application_End(object sender, EventArgs e)
 {
     // Serilog.
     using (var log = new LoggerConfiguration().ReadFrom.AppSettings().CreateLogger())
     {
         log.Information("Application_End: the SLLInvoices application is being shut down");
     }
 }
开发者ID:txsll,项目名称:SLLInvoices,代码行数:8,代码来源:Global.asax.cs

示例6: ParameterizedLog

 public static void ParameterizedLog()
 {
     // Create Logger
     var logger = new LoggerConfiguration()
         .WriteTo.Console()
         .CreateLogger();
     // write structured data
     logger.Information("Processed {Number} records in {Time} ms", 500, 120);
 }
开发者ID:andyfengc,项目名称:SerilogTutorial,代码行数:9,代码来源:HelloSerilog.cs

示例7: HelloLog

 public static void HelloLog()
 {
     // Create Logger
     var logger = new LoggerConfiguration()
             .WriteTo.Console()
             .CreateLogger();
     // Output logs
     logger.Information("Hello, Serilog!");
 }
开发者ID:andyfengc,项目名称:SerilogTutorial,代码行数:9,代码来源:HelloSerilog.cs

示例8: Main

        static void Main(string[] args)
        {

            //Configuration by AppSettings
            var logger = new LoggerConfiguration()
                .ReadFrom.AppSettings()
                .MinimumLevel.Debug()
                .Enrich.WithThreadId()
                .Enrich.WithProperty("MyMetaProperty", "Oh! the beautiful value!")
                .WriteTo.ColoredConsole()
                .CreateLogger();

            ////Configuration by code
            //var logger = new LoggerConfiguration()
            //    .MinimumLevel.Debug()
            //    .Enrich.WithThreadId()
            //    .Enrich.WithProperty("MyMetaProperty", "Oh! the beautiful value!")
            //    .WriteTo.ColoredConsole()
            //    .WriteTo.BrowserConsole(port: 9999, buffer: 50)
            //    .CreateLogger();

            OpenBrowserToBrowserLogUrl();

            logger.Information("Hello!");
            Thread.Sleep(1000);
            for (int i = 0; i < 100000; i++)
            {
                logger.Information("Hello this is a log from a server-side process!");
                Thread.Sleep(100);
                logger.Warning("Hello this is a warning from a server-side process!");
                logger.Debug("... and here is another log again ({IndexLoop})", i);
                Thread.Sleep(200);
                try
                {
                    ThrowExceptionWithStackTrace(4);
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "An error has occured, really?");
                }

                Thread.Sleep(1000);
            }
        }
开发者ID:pmiossec,项目名称:BrowserLog,代码行数:44,代码来源:Program.cs

示例9: Run

 public static void Run()
 {
     var logger = new LoggerConfiguration()
         .WriteTo.ColoredConsole()
         .WriteTo.RollingFile(@"D:\Log-{Date}.txt")
         .CreateLogger();
     var appointment =
         new { Id = 1, Subject = "Meeting of database migration", Timestamp = new DateTime(2015, 3, 12) };
     logger.Information("An appointment is booked successfully: {@appountment}", appointment);
     logger.Error("Failed to book an appointment: {@appountment}", appointment);
 }
开发者ID:andyfengc,项目名称:SerilogTutorial,代码行数:11,代码来源:BasicLogger.cs

示例10: Message

		public void Message( LoggerHistorySink sut, string message )
		{
			var logger = new LoggerConfiguration().WriteTo.Sink( sut ).CreateLogger();

			logger.Information( message );

			var item = sut.Events.Only();
			Assert.NotNull( item );

			Assert.Equal( LogEventLevel.Information, item.Level );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:11,代码来源:LoggerHistorySinkTests.cs

示例11: Main

        static void Main(string[] args)
        {
            var logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .WriteTo.ColoredConsole()
                .WriteTo.Elasticsearch("http://localhost:9200")
                .CreateLogger();

            logger.Information("Here is an informational message");
            logger.Debug("Some debug level info");
            logger.Error("And error level info");
        }
开发者ID:PyroJoke,项目名称:LogPatterns,代码行数:12,代码来源:Program.cs

示例12: TemplateLog

 public static void TemplateLog()
 {
     // Create Logger
     var logger = new LoggerConfiguration()
         .WriteTo.Console()
         .CreateLogger();
     // prepare data
     var order = new {Id = 12, Total = 128.50, CustomerId = 72};
     var customer = new {Id = 72, Name = "John Smith"};
     // write log message
     logger.Information("New orders {OrderId} by {Customer}", order.Id, customer);
 }
开发者ID:andyfengc,项目名称:SerilogTutorial,代码行数:12,代码来源:HelloSerilog.cs

示例13: SetLevel

 public static void SetLevel()
 {
     var logger = new LoggerConfiguration()
      .MinimumLevel.Debug()
      .WriteTo.ColoredConsole()
      .CreateLogger();
     var appointment =
         new { Id = 1, Subject = "Meeting of database migration", Timestamp = new DateTime(2015, 3, 12) };
     logger.Verbose("You will not see this log");
     logger.Information("An appointment is booked successfully: {@appountment}", appointment);
     logger.Error("Failed to book an appointment: {@appountment}", appointment);
 }
开发者ID:andyfengc,项目名称:SerilogTutorial,代码行数:12,代码来源:CustomizedLogger.cs

示例14: Main

        public static void Main(string[] args)
        {
            var log = new LoggerConfiguration()
                .WriteTo.Console()
                .MinimumLevel.Debug()
                .CreateLogger();

            var options = new Options();
            if (CommandLine.Parser.Default.ParseArguments(args, options) == false)
            {
                log.Fatal("Problem parsing options!");
                Environment.Exit(-1);
            }

            log.Information("Processing migrations");
            var connectionStringVal = Config.ConnectionStrings[options.ConnectionStringName];
            if (connectionStringVal == null)
            {
                log.Fatal("ERROR: Unable to get connection string from configuration");
                Environment.Exit(-2);
            }

            var connectionString = connectionStringVal.ConnectionString;
            log.Debug("Connection string is {connectionString}", connectionString);

            var runner = new FluentRunner(connectionString, typeof(DipsContext).Assembly);

            try
            {
                runner.MigrateToLatest();
            }
            catch (Exception e)
            {
                log.Fatal(e, "ERROR: problem while running migrations!");
                Environment.Exit(-3);
            }

            log.Information("Migrations run successfully");
        }
开发者ID:jhonner72,项目名称:plat,代码行数:39,代码来源:Program.cs

示例15: DipsService

 public DipsService()
 {
     var log = new LoggerConfiguration().Destructure.UsingAttributes().ReadAppSettings().CreateLogger();
     Log.Logger = log;
     InitializeComponent();
     var configuration = SetConfiguration();
     ValidateCodeline = new ValidateCodelineProcessingService(configuration, log);
     ValidateTransaction = new ValidateTransctionRequestProcessingService(configuration, log);
     CheckThirdParty = new CheckThirdPartyProcessingService(configuration, log);
     CorrectCodeline = new CorrectCodelineProcessingService(configuration, log);
     CorrectTransaction = new CorrectTransactionProcessingService(configuration, log);
     GenerateVoucher = new GenerateCorrespondingVoucherProcessingService(configuration, log);
     GetVoucher = new GetVouchersInformationProcessingService(configuration, log);
     log.Information("Dips Service Initialised");
 }
开发者ID:jhonner72,项目名称:plat,代码行数:15,代码来源:DipsService.cs


注:本文中的Serilog.LoggerConfiguration.Information方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。