本文整理汇总了C#中Logger.Critical方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.Critical方法的具体用法?C# Logger.Critical怎么用?C# Logger.Critical使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger.Critical方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main()
{
ILayout simpleLayout = new SimpleLayout();
IAppender consoleAppender = new ConsoleAppender(simpleLayout);
var fileAppender = new FileAppender(simpleLayout);
fileAppender.File = "../../log.txt";
var logger = new Logger(consoleAppender, fileAppender);
logger.Error("Error parsing JSON.");
logger.Info(string.Format("User {0} successfully registered.", "Dobri"));
logger.Warn("Warning - missing files.");
var xmlLayout = new XmlLayout();
consoleAppender = new ConsoleAppender(xmlLayout);
logger = new Logger(consoleAppender);
logger.Fatal("mscorlib.dll does not respond");
logger.Critical("No connection string found in App.config");
consoleAppender = new ConsoleAppender(simpleLayout);
consoleAppender.ReportLevel = ReportLevel.Error;
logger = new Logger(consoleAppender);
logger.Info("Everything seems fine");
logger.Warn("Warning: ping is too high - disconnect imminent");
logger.Error("Error parsing request");
logger.Critical("No connection string found in App.config");
logger.Fatal("mscorlib.dll does not respond");
}
示例2: TestXmlLayuot
private static void TestXmlLayuot()
{
var xmlLayout = new XmlLayuot();
var consoleAppender = new ConsoleAppender(xmlLayout);
var logger = new Logger(consoleAppender);
logger.Fatal("mscorlib.dll does not respond");
logger.Critical("No connection string found in App.config");
}
示例3: Main
static void Main(string[] args)
{
ILayout simpleLayout = new SimpleLayout();
IAppender consoleAppender = new ConsoleAppender(simpleLayout);
consoleAppender.ReportLevel = ReportLevel.Error;
ILogger logger = new Logger(consoleAppender);
logger.Info("Everything seems fine");
logger.Warn("Warning: ping is too high - disconnect imminent");
logger.Error("Error parsing request");
logger.Critical("No connection string found in App.config");
logger.Fatal("mscorlib.dll does not respond");
}
示例4: TestTreshold
private static void TestTreshold()
{
var simpleLayout = new SimpleLayuot();
var consoleAppender = new ConsoleAppender(simpleLayout);
consoleAppender.Treshold = ReportLevel.Error;
var logger = new Logger(consoleAppender);
logger.Info("Everything seems fine");
logger.Warn("Warning: ping is too high - disconnect imminent");
logger.Error("Error parsing request");
logger.Critical("No connection string found in App.config");
logger.Fatal("mscorlib.dll does not respond");
}
示例5: Main
public static void Main()
{
try
{
var simpleLayout = new SimpleLayout();
var xmlLayout = new XmlLayout();
IAppender consoleAppender = new ConsoleAppender(simpleLayout);
IAppender fileAppender = new FileAppender(simpleLayout);
fileAppender.File = "../../log.txt";
IAppender fileAppenderXml = new FileAppender(xmlLayout);
fileAppenderXml.File = "../../log.xml";
ILogger logger = new Logger(consoleAppender, fileAppender, fileAppenderXml);
// add in logs
logger.Error("Error parsing JSON.");
logger.Info(string.Format("User {0} successfully registered.", "Pesho"));
logger.Warn("Warn - missing files.");
logger.Fatal("mscorlib.dll does not respond");
logger.Critical("No connection string found in App.config");
logger.Info("Everything seems fine");
logger.Warn("Warning: ping is too high - disconnect imminent");
logger.Error("Error parsing request");
logger.Critical("No connection string found in App.config");
logger.Fatal("mscorlib.dll does not respond");
}
catch (ArgumentException ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine();
}
示例6: Main
public static void Main()
{
var simpleLayout = new SimpleLayout();
var jsonLayout = new JsonLayout();
// var myLayout = new SoftUniLayout();
var consoleAppender = new ConsoleAppender(simpleLayout);
consoleAppender.ReportLevel = ReportLevel.Error;
consoleAppender.ReportLevel = ReportLevel.Error;
var fileAppender = new FileAppendder(jsonLayout, "../../Log.txt");
fileAppender.ReportLevel = ReportLevel.Error;
var logger = new Logger(consoleAppender, fileAppender);
logger.Error("Error parsing JSON.");
logger.Warning("User John successfully registered");
logger.Info("Everything seems fine");
logger.Warning("Warning: ping is too high - disconnect imminent");
logger.Error("Error parsing request");
logger.Critical("No connection string found in App.config");
logger.Fatal("mscorlib.dll does not respond");
fileAppender.Close();
}
示例7: Main
/// <summary>
/// This is the entry point of the service host process.
/// </summary>
static void Main()
{
const string SystemName = @"Protocol Gateway Front End";
const string ComponentName = @"Registration Application";
ILogger logger = new Logger(SystemName);
Guid traceId = Guid.NewGuid();
try
{
logger.Informational(traceId, ComponentName, "Initializing FrontEndType.");
ServiceRuntime.RegisterServiceAsync("FrontEndType", context => new FrontEnd(traceId, SystemName, context)).GetAwaiter().GetResult();
logger.Informational(traceId, ComponentName, "Services registered.");
// Prevents this host process from terminating so services keep running.
Thread.Sleep(Timeout.Infinite);
}
catch (Exception e)
{
logger.Critical(traceId, ComponentName, "Error during registration of type {0}.", new object[] { typeof(FrontEnd).Name }, e);
throw;
}
}
示例8: Main
public static void Main()
{
Logger logger = new Logger();
logger.Critical("Out of memory");
logger.Info("Unused local variable 'name'");
}
示例9: PassEmptyStringParameterToLoggerCritical_ThrowException
public void PassEmptyStringParameterToLoggerCritical_ThrowException()
{
var logger = new Logger(new ConsoleAppender(new SimpleLayout()));
logger.Critical(" ");
}
示例10: PassNullParameterToLoggerCritical_ThrowException
public void PassNullParameterToLoggerCritical_ThrowException()
{
var logger = new Logger(new ConsoleAppender(new SimpleLayout()));
logger.Critical(null);
}