本文整理汇总了C#中ILogger.LogCritical方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.LogCritical方法的具体用法?C# ILogger.LogCritical怎么用?C# ILogger.LogCritical使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.LogCritical方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StudentsController
public StudentsController(IOptions<RedisConfig> redisConfig, ILogger<StudentsController> logger)
{
String redisConnection = redisConfig.Value.RedisConnection;
_logger = logger;
_logger.LogCritical("logging redis connection: " + redisConnection);
_studentRepository = new StudentRepository(ConnectionMultiplexer.Connect(redisConnection).GetDatabase(0));
_classRepository = new ClassRepository(ConnectionMultiplexer.Connect(redisConnection).GetDatabase(0));
}
示例2: HabitService
public HabitService(GetHabitsContext dbContext, IHttpContextAccessor httpContextAccessor, ILoggerFactory loggerFactory, ApplicationHelper appHelper)
{
_dbContext = dbContext;
_httpContext = httpContextAccessor.HttpContext;
_logger = loggerFactory.CreateLogger<HabitService>();
_appHelper = appHelper;
var claimUserId = _httpContext.User.FindFirst(appHelper.TypeClaimUserId);
if (claimUserId == null)
{
_logger.LogCritical("HttpContext doesn't contain UserId claim");
_userId = Guid.NewGuid().ToString();
}
else
{
_userId = claimUserId.Value;
}
}
示例3: TestController
public TestController(ILogger<TestController> logger)
{
_logger = logger;
_logger.LogCritical("Logger: TestController constructor");
}