本文整理汇总了C#中NLog.LogLevel.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# LogLevel.ToString方法的具体用法?C# LogLevel.ToString怎么用?C# LogLevel.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NLog.LogLevel
的用法示例。
在下文中一共展示了LogLevel.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: serializeMessage
protected override byte[] serializeMessage(LogLevel logLevel, string message)
{
var formattedMessage = formatLogMessage(logLevel.ToString(), message);
var bytes = Encoding.UTF8.GetBytes(formattedMessage).ToList();
bytes.Add(0);
return bytes.ToArray();
}
示例2: IsEnabled
/// <summary>
/// Checks whether the specified log level is enabled.
/// </summary>
/// <param name="level"></param>
/// <param name="bool"></param>
/// <returns></returns>
public virtual bool IsEnabled(LogLevel level, bool defaultValue)
{
string value = ConfigurationSettings.AppSettings["Logging." + level.ToString() + ".Enabled"];
if (value != null && value != String.Empty)
{
return Convert.ToBoolean(value);
}
else
return defaultValue;
}
示例3: testAllLogLevels
void testAllLogLevels(LogLevel logLevel, bool trace, bool debug, bool info, bool warn, bool error, bool fatal)
{
context[logLevel.ToString()] = () => {
before = () => _logger.logLevel = logLevel;
it[logs(trace) + " trace"] = () => testLogLevel(_logger.Trace, LogLevel.Trace, trace);
it[logs(debug) + " debug"] = () => testLogLevel(_logger.Debug, LogLevel.Debug, debug);
it[logs(info) + " info"] = () => testLogLevel(_logger.Info, LogLevel.Info, info);
it[logs(warn) + " warn"] = () => testLogLevel(_logger.Warn, LogLevel.Warn, warn);
it[logs(error) + " error"] = () => testLogLevel(_logger.Error, LogLevel.Error, error);
it[logs(fatal) + " fatal"] = () => testLogLevel(_logger.Fatal, LogLevel.Fatal, fatal);
};
}
示例4: SetupNLog
protected void SetupNLog(LogLevel logLevel) {
var nLogViewerTarget = GetNLogViewerLoggingTarget();
var consoleTarget = GetConsoleLoggingTarget();
NLogConfigurator.Configure(new object[] {nLogViewerTarget, consoleTarget}, logLevel.ToString());
}
示例5: FormatMessage
public string FormatMessage(Logger logger, LogLevel logLevel, string message)
{
var logLevelStr = ("[" + logLevel.ToString().ToUpper() + "]").PadRight(_maxLogLevelLength);
return string.Format(Format, logLevelStr, logger.name, message);
}
示例6: IsEnabledByDefault
/// <summary>
/// Gets the default "is enabled" setting for the provided log level.
/// </summary>
/// <param name="level"></param>
/// <returns></returns>
public virtual bool IsEnabledByDefault(LogLevel level)
{
if (Defaults.ContainsKey(level.ToString()))
return Defaults[level.ToString()];
else
return false;
}