Class LogSource
Represents a named source in a log.
The Source and the Scope of a LogEntry are just names devised by the developer.
A Source could be the full name of a class, such as a MainForm, an action url or any other suitable string and it marks all the log messages produced by this source.
A Scope could be the name of a method or the name of a group of methods, or whatever.
The Logger class provides a method to create a Source.
The Source creates a Default Scope when it is created. The developer never gets a reference to a Scope.
The developer may call EnterScope(...) passing it a Scope name.
The ExitScope() exits the last entered Scope. The Default Scope cannot exited.
It is even safe to call ExitScope() more times than the existing Scopes.
Any call to Source log methods, such as Log(), Debug(), Error(), etc. produces a LogEntry marked with the Source name and the name of the latest Scope.
public class LogSource
- Inheritance
-
LogSource
- Inherited Members
- Extension Methods
Constructors
LogSource(string)
Constructor
public LogSource(string Name)
Parameters
Namestring
Properties
Active
When false no logs are recorded. Defaults to true.
public bool Active { get; set; }
Property Value
Name
The name of this log source.
public string Name { get; }
Property Value
Methods
Create(string)
Creates and returns a source
public static LogSource Create(string Name)
Parameters
Namestring
Returns
Debug(string)
Logs a debug level message
public void Debug(string Text)
Parameters
Textstring
Debug(string, string)
Logs a debug level message
public void Debug(string EventId, string Text)
Parameters
EnterScope(string, Dictionary<string, object>)
Begins a new log scope. A log scope is just a label under which next log messages are recorded. Log scopes can be nested.
The Name of a scope is the label of the scope.
Scope params are attached to each log message in that scope.
public void EnterScope(string ScopeName, Dictionary<string, object> ScopeParams = null)
Parameters
ScopeNamestringScopeParamsDictionary<string, object>
Error(Exception)
Logs an error message
public void Error(Exception Ex)
Parameters
ExException
Error(string)
Logs an error message
public void Error(string Text)
Parameters
Textstring
Error(string, Exception)
Logs an error message
public void Error(string EventId, Exception Ex)
Parameters
Error(string, string)
Logs an error message
public void Error(string EventId, string Text)
Parameters
ExitScope()
Exits the last entered scope.
public void ExitScope()
Info(string)
Logs an info level message
public void Info(string Text)
Parameters
Textstring
Info(string, string)
Logs an info level message
public void Info(string EventId, string Text)
Parameters
Log(string, LogLevel, Exception, string, Dictionary<string, object>)
Logs a message
public void Log(string EventId, LogLevel Level, Exception Ex, string Text, Dictionary<string, object> Params)
Parameters
Log(string, LogLevel, string, Dictionary<string, object>)
Logs a message
public void Log(string EventId, LogLevel Level, string Text, Dictionary<string, object> Params)
Parameters
Log(LogLevel, Exception, string, Dictionary<string, object>)
Logs a message
public void Log(LogLevel Level, Exception Ex, string Text, Dictionary<string, object> Params)
Parameters
Log(LogLevel, string, Dictionary<string, object>)
Logs a message
public void Log(LogLevel Level, string Text, Dictionary<string, object> Params)
Parameters
LevelLogLevelTextstringParamsDictionary<string, object>
Trace(string)
Logs a trace level message
public void Trace(string Text)
Parameters
Textstring
Trace(string, string)
Logs a trace level message
public void Trace(string EventId, string Text)
Parameters
Warn(string)
Logs a warn levelmessage
public void Warn(string Text)
Parameters
Textstring
Warn(string, string)
Logs a warn level message
public void Warn(string EventId, string Text)