本文整理汇总了C#中Serilog.LoggerConfiguration.Fatal方法的典型用法代码示例。如果您正苦于以下问题:C# LoggerConfiguration.Fatal方法的具体用法?C# LoggerConfiguration.Fatal怎么用?C# LoggerConfiguration.Fatal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Serilog.LoggerConfiguration
的用法示例。
在下文中一共展示了LoggerConfiguration.Fatal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fatal
public void Fatal( LoggerHistorySink sut, string message, FatalApplicationException error )
{
var logger = new LoggerConfiguration().WriteTo.Sink( sut ).CreateLogger();
logger.Fatal( error, message );
var item = sut.Events.Only();
Assert.NotNull( item );
Assert.Equal( LogEventLevel.Fatal, item.Level );
Assert.Contains( message, item.RenderMessage() );
Assert.Equal( error, item.Exception );
}
示例2: 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");
}
示例3: Main
static void Main(string[] args)
{
var log = new LoggerConfiguration()
.WriteTo.ColoredConsole()
.CreateLogger();
try
{
// https://github.com/serilog/serilog/wiki/Getting-Started
//log.Information("Starting log...");
var array = new int[] { 3, 1, 2, 4, 3 };
var result = TimeComplexity.solutionTapeEquilibrium(array);
log.Information($"Result:{result}.");
Console.ReadLine();
}
catch (Exception exception)
{
log.Fatal(exception, "Fatal error");
}
}