本文整理汇总了C#中LoggerLevel类的典型用法代码示例。如果您正苦于以下问题:C# LoggerLevel类的具体用法?C# LoggerLevel怎么用?C# LoggerLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoggerLevel类属于命名空间,在下文中一共展示了LoggerLevel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WriteLine
static void WriteLine(LoggerLevel level, string message)
{
ConsoleColor color = ConsoleColor.White;
switch (level)
{
case LoggerLevel.Info:
color = ConsoleColor.Green;
break;
case LoggerLevel.Debug:
color = ConsoleColor.White;
break;
case LoggerLevel.Warn:
color = ConsoleColor.Yellow;
break;
case LoggerLevel.Error:
color = ConsoleColor.Red;
break;
default:
break;
}
if (WaitForInput)
{
message = Environment.NewLine + message;
}
Console.ForegroundColor = color;
Console.WriteLine(message);
Console.ResetColor();
if (WaitForInput)
{
Console.Write(Prefix);
}
}
开发者ID:bigsupersniper,项目名称:SimpleDeployServices,代码行数:32,代码来源:ConsoleLogger.cs
示例2: Output
// ----------------------------------------------------------------------
protected override void Output( LoggerLevel level, object message, Exception exception )
{
buffer.Append( level.ToString() );
buffer.Append( ": " );
buffer.AppendLine( message == null ? "null" : message.ToString() );
Output( exception );
}
开发者ID:Shereef,项目名称:RTF-to-HTML-Converter-Class-Library-DLL,代码行数:8,代码来源:StringBuilderLogger.cs
示例3: WebFarmRole
/// <summary>
/// Instantiates an Azure Web Farm Role.
/// </summary>
/// <param name="logFactory">The Castle.Core Logger Factory to use for logging, AzureDiagnosticsTraceListenerFactory by default</param>
/// <param name="loggerLevel">The Castle.Core Log Level to use for logging, LoggerLevel.Info by default</param>
/// <param name="diagnosticsLogLevel">The log level to use for Azure Diagnostics, LogLevel.Information by default</param>
public WebFarmRole(ILoggerFactory logFactory = null, LoggerLevel? loggerLevel = null, LogLevel? diagnosticsLogLevel = null)
{
_logFactory = logFactory ?? new AzureDiagnosticsTraceListenerFactory();
_logLevel = loggerLevel ?? LoggerLevel.Info;
_logger = _logFactory.Create(GetType(), _logLevel);
_diagnosticsLogLevel = diagnosticsLogLevel ?? LogLevel.Information;
}
开发者ID:abstractiondev,项目名称:AzureWebFarm,代码行数:13,代码来源:WebFarmRole.cs
示例4: Create
public override ILogger Create(string name, LoggerLevel level)
{
StreamLogger logger =
new StreamLogger(name, new FileStream(name + ".log", FileMode.Append, FileAccess.Write), Encoding.Default);
logger.Level = level;
return logger;
}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:7,代码来源:StreamLoggerFactory.cs
示例5: BackgroundWorkerService
public BackgroundWorkerService(string sitesPath, string executablePath, ILoggerFactory loggerFactory, LoggerLevel logLevel)
{
_executablePath = executablePath;
_executables = new Dictionary<string, List<Executable>>();
_executableFinder = new ExecutableFinder(sitesPath);
_logger = loggerFactory.Create(GetType(), logLevel);
}
开发者ID:MRCollective,项目名称:AzureWebFarm,代码行数:7,代码来源:BackgroundWorkerService.cs
示例6: Write
public override void Write(string logText, LoggerLevel loggerLevel, string source = "", string category = "", string metaData = "")
{
lock (this)
{
var useSource = string.Format(
"{0}{1}{2}",
GlobalSource,
(GlobalSource != "" & source != "" ? ":" : ""),
source);
var dateString = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff");
_file.WriteLine(
"{0}|{1}|{2}|{3}|{4}",
dateString,
useSource,
loggerLevel,
metaData,
logText);
if (FlushAfterEachWrite)
{
_file.Flush();
}
}
}
开发者ID:HaKDMoDz,项目名称:Psy,代码行数:26,代码来源:FileLogger.cs
示例7: Log
public void Log(String logMessage, LoggerLevel messageLevel, params ComponentType[] messageComponentTypes)
{
if (messageLevel < _logThreshholdLevel) { return; }
string date = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");
string level = messageLevel == LoggerLevel.NULL ? " " : messageLevel.ToString();
string type = messageComponentTypes[0] == ComponentType.NULL ? " " : ComponentTypeUtil.GetCodeFromType(messageComponentTypes[0]);
// If no component types are specified, log everything.
if (componentTypesToLog == null || componentTypesToLog.Count == 0)
{
_streamWriter.WriteLine(date + " | " + level + " | " + type + " | " + logMessage);
_streamWriter.Flush();
return;
}
else // Else, only log messages matching one of the specified component types.
{
foreach (ComponentType componentType in messageComponentTypes)
{
if (componentTypesToLog.Contains(componentType))
{
_streamWriter.WriteLine(date + " | " + level + " | " + type + " | " + logMessage);
_streamWriter.Flush();
return;
}
}
}
}
开发者ID:WorldBeard,项目名称:worldbeardsource,代码行数:28,代码来源:Logger.cs
示例8: FormatMessage
private static string FormatMessage(LoggerLevel loggerLevel, string message)
{
string messageIdentifier = String.Empty;
switch (loggerLevel)
{
case LoggerLevel.Off:
messageIdentifier = " ";
break;
case LoggerLevel.Error:
case LoggerLevel.Fatal:
messageIdentifier = "X";
break;
case LoggerLevel.Warn:
messageIdentifier = "!";
break;
case LoggerLevel.Info:
messageIdentifier = "-";
break;
case LoggerLevel.Debug:
messageIdentifier = "+";
break;
}
DateTime dateTime = DateTime.Now;
return String.Format("[{0}-{1}] {2} {3}", dateTime.ToShortDateString(), dateTime.ToLongTimeString(), messageIdentifier, message);
}
开发者ID:harlam357,项目名称:hfm-net,代码行数:27,代码来源:Logger.cs
示例9: IISManager
public IISManager(string localSitesPath, string tempSitesPath, ISyncStatusRepository syncStatusRepository, ILoggerFactory loggerFactory, LoggerLevel logLevel)
{
_syncStatusRepository = syncStatusRepository;
_localSitesPath = localSitesPath;
_tempSitesPath = tempSitesPath;
_logger = loggerFactory.Create(GetType(), logLevel);
}
开发者ID:abstractiondev,项目名称:AzureWebFarm,代码行数:7,代码来源:IISManager.cs
示例10: SetLogLevel
public static void SetLogLevel(LoggerLevel logLevel)
{
lock (lockObject)
{
maxLogLevel = logLevel;
}
}
开发者ID:marinehero,项目名称:microserver,代码行数:7,代码来源:Logger.cs
示例11: ConsoleLogger
public ConsoleLogger(LoggerLevel level, bool console = true, bool trace = false, bool debug = false) :
base(level)
{
_console = console;
_debug = debug;
_trace = trace;
_color = Console.BackgroundColor;
}
开发者ID:kendarorg,项目名称:Node.Cs.Old,代码行数:8,代码来源:Log4NetLogger.cs
示例12: Log
protected override void Log(LoggerLevel loggerLevel, string loggerName, string message, Exception exception)
{
Console.Out.WriteLine("[{0} - {3}] '{1}' {2}", loggerLevel, loggerName, message, DateTime.Now.ToLongTimeString());
if (exception == null)
return;
Console.Out.WriteLine("[{0} - {5}] '{1}' {2}: {3} {4}", loggerLevel, loggerName,
exception.GetType().FullName, exception.Message, exception.StackTrace, DateTime.Now.ToLongTimeString());
}
开发者ID:EDOlsson,项目名称:White,代码行数:8,代码来源:WhiteDefaultLogger.cs
示例13: LogEntry
public static void LogEntry(LoggerLevel level, string message, int code)
{
LogEntry log = new Code.LogEntry() { Level = level, Message = message, Code = code };
IDocumentSession conn = JournalDb.GetDBConnection();
conn.Store(log);
conn.SaveChanges();
}
开发者ID:punkcoder,项目名称:JournalApp,代码行数:8,代码来源:Logger.cs
示例14: Create
public virtual ILogger Create(Type type, LoggerLevel level)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
return Create(type.FullName, level);
}
开发者ID:ArthurYiL,项目名称:JustMockLite,代码行数:9,代码来源:AbstractLoggerFactory.cs
示例15: LoggerEvent
// ----------------------------------------------------------------------
public LoggerEvent( LoggerLevel level, string source, string context, string message, Exception caughtException )
{
int levelValue = (int)level;
this.level = levelValue < 0 ? LoggerLevel.Fatal : ( levelValue > 4 ? LoggerLevel.Fatal : level );
this.source = ArgumentCheck.NonemptyTrimmedString( source, "source" );
this.context = context ?? string.Empty;
this.message = message ?? string.Empty;
this.caughtException = caughtException;
}
开发者ID:Shereef,项目名称:RTF-to-HTML-Converter-Class-Library-DLL,代码行数:10,代码来源:LoggerEvent.cs
示例16: Initialize
public static void Initialize(ILogger newLogger, LoggerLevel logLevel)
{
if (logger != null)
{
throw new InvalidOperationException("Logger may only be initialized once");
}
logger = newLogger;
maxLogLevel = logLevel;
}
开发者ID:marinehero,项目名称:microserver,代码行数:9,代码来源:Logger.cs
示例17: WriteEntry
public void WriteEntry(LoggerLevel level, string format, params object[] args)
{
var now = DateTime.Now.ToLongTimeString();
var message = string.Format(format, args);
textWriter.WriteLine("[{0}] {1} {2}", now, level, message);
textWriter.Flush();
}
开发者ID:joenjuki,项目名称:design-patterns,代码行数:9,代码来源:Logger.cs
示例18: WhiteLogRedirector
/// <summary>
/// Initializes a new instance of the <see cref="WhiteLogRedirector"/> class.
/// </summary>
/// <param name="name">The name for the logger.</param>
/// <param name="level">The default log level.</param>
/// <param name="diagnostics">The object that provides the logging for the application.</param>
/// <exception cref="ArgumentNullException">
/// Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
/// </exception>
public WhiteLogRedirector(string name, LoggerLevel level, SystemDiagnostics diagnostics)
: base(name, level)
{
{
Lokad.Enforce.Argument(() => diagnostics);
}
m_Diagnostics = diagnostics;
}
开发者ID:pvandervelde,项目名称:Apollo,代码行数:18,代码来源:WhiteLogRedirector.cs
示例19: Log
/// <summary>
/// A Common method to log.
/// </summary>
/// <param name = "loggerLevel">The level of logging</param>
/// <param name = "loggerName">The name of the logger</param>
/// <param name = "message">The Message</param>
/// <param name = "exception">The Exception</param>
protected override void Log(LoggerLevel loggerLevel, String loggerName, String message, Exception exception)
{
Console.Out.WriteLine("[{0}] '{1}' {2}", loggerLevel, loggerName, message);
if (exception != null)
{
Console.Out.WriteLine("[{0}] '{1}' {2}: {3} {4}", loggerLevel, loggerName, exception.GetType().FullName,
exception.Message, exception.StackTrace);
}
}
开发者ID:brianmatic,项目名称:n2cms,代码行数:17,代码来源:ConsoleLogger.cs
示例20: Write
/// <summary>
/// Write to the log.
/// </summary>
/// <param name="logText">Text to log</param>
/// <param name="loggerLevel">Optional.</param>
public static void Write(string logText, LoggerLevel loggerLevel = LoggerLevel.Debug, string source = "")
{
foreach (var logger in Loggers)
{
if (!logger.WillHandle(loggerLevel))
break;
logger.Write(logText, loggerLevel, source);
}
}
开发者ID:HaKDMoDz,项目名称:Psy,代码行数:15,代码来源:Logger.cs
注:本文中的LoggerLevel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论