本文整理汇总了C#中Logger.Warn方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.Warn方法的具体用法?C# Logger.Warn怎么用?C# Logger.Warn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger.Warn方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: TestLogging
private static void TestLogging()
{
var logger = new Logger<CommonRegistry>();
logger.Debug("Testing Debug Log.");
logger.Info("Testing Info Log.");
logger.Warn("Testing Warn Log.");
logger.Error("Testing Error Log.");
}
示例3: TestFileAppender
private static void TestFileAppender()
{
var simpleLayout = new SimpleLayuot();
var 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($"User {"Pesho"} successfully registered.");
logger.Warn("Warning - missing files.");
}
示例4: 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");
}
示例5: 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");
}
示例6: 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();
}
示例7: Main
private static void Main(string[] args)
{
SetupNLog();
SetupPatterns();
_logger = LogManager.GetCurrentClassLogger();
if (!CheckForDotnet46())
{
_logger.Warn(".net 4.6 not detected. Please install .net 4.6 and try again.");
return;
}
var p = new FluentCommandLineParser<ApplicationArguments>
{
IsCaseSensitive = false
};
p.Setup(arg => arg.File)
.As('f')
.WithDescription("File to search. This is required").Required();
p.Setup(arg => arg.SaveTo)
.As('o')
.WithDescription("File to save results to");
p.Setup(arg => arg.SqliteOutput)
.As("sql")
.WithDescription("Set a file path to output string into SQLite format");
p.Setup(arg => arg.GetAscii)
.As('a')
.SetDefault(true)
.WithDescription("If set, look for ASCII strings. Default is true. Use -a false to disable");
p.Setup(arg => arg.GetUnicode)
.As('u')
.SetDefault(true)
.WithDescription("If set, look for Unicode strings. Default is true. Use -u false to disable");
p.Setup(arg => arg.MinimumLength)
.As('m').SetDefault(3).WithDescription("Minimum string length. Default is 3");
p.Setup(arg => arg.BlockSizeMB)
.As('b').SetDefault(512).WithDescription("Chunk size in MB. Valid range is 1 to 1024. Default is 512");
p.Setup(arg => arg.Quiet)
.As('q').SetDefault(false).WithDescription("Quiet mode (Do not show header or total number of hits)");
p.Setup(arg => arg.MaximumLength)
.As('x').SetDefault(-1).WithDescription("Maximum string length. Default is unlimited");
p.Setup(arg => arg.GetPatterns)
.As('p').SetDefault(false).WithDescription("Display list of built in regular expressions");
p.Setup(arg => arg.LookForString)
.As("ls")
.SetDefault(string.Empty)
.WithDescription("String to look for. When set, only matching strings are returned.");
p.Setup(arg => arg.LookForRegex)
.As("lr")
.SetDefault(string.Empty)
.WithDescription("Regex to look for. When set, only matching strings are returned.");
p.Setup(arg => arg.SortAlpha)
.As("sa").SetDefault(false).WithDescription("Sort results alphabetically");
p.Setup(arg => arg.SortLength)
.As("sl").SetDefault(false).WithDescription("Sort results by length");
// p.Setup(arg => arg.ShowOffset).As('o').SetDefault(false).WithDescription("Show offset to hit before string");
var header =
$"bstrings version {Assembly.GetExecutingAssembly().GetName().Version}" +
"\r\n\r\nAuthor: Eric Zimmerman ([email protected])" +
"\r\nhttps://github.com/EricZimmerman/bstrings";
var footer = @"Examples: bstrings.exe -f ""C:\Temp\UsrClass 1.dat"" --ls URL" + "\r\n\t " +
@" bstrings.exe -f ""C:\Temp\someFile.txt"" --lr guid" + "\r\n\t " +
@" bstrings.exe -f ""C:\Temp\someOtherFile.txt"" --lr cc -sa" + "\r\n\t " +
@" bstrings.exe -f ""C:\Temp\someOtherFile.txt"" --lr cc -sa -m 15 -x 22" + "\r\n\t " +
@" bstrings.exe -f ""C:\Temp\UsrClass 1.dat"" --ls mui -sl" + "\r\n\t ";
p.SetupHelp("?", "help").WithHeader(header).Callback(text => _logger.Info(text + "\r\n" + footer));
var result = p.Parse(args);
if (result.HelpCalled)
{
return;
}
if (p.Object.GetPatterns)
{
_logger.Info("Name \t\tDescription");
foreach (var regExPattern in _regExPatterns)
{
var desc = _regExDesc[regExPattern.Key];
_logger.Info($"{regExPattern.Key}\t{desc}");
//.........这里部分代码省略.........
示例8: PassNullParameterToLoggerWarn_ThrowException
public void PassNullParameterToLoggerWarn_ThrowException()
{
var logger = new Logger(new ConsoleAppender(new SimpleLayout()));
logger.Warn(null);
}
示例9: PassEmptyStringParameterToLoggerWarn_ThrowException
public void PassEmptyStringParameterToLoggerWarn_ThrowException()
{
var logger = new Logger(new ConsoleAppender(new SimpleLayout()));
logger.Warn(" ");
}