Table of Contents

Class LogSource

Namespace
Tripous.Logging
Assembly
Tripous.Logging.dll

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

Name string

Properties

Active

When false no logs are recorded. Defaults to true.

public bool Active { get; set; }

Property Value

bool

Name

The name of this log source.

public string Name { get; }

Property Value

string

Methods

Create(string)

Creates and returns a source

public static LogSource Create(string Name)

Parameters

Name string

Returns

LogSource

Debug(string)

Logs a debug level message

public void Debug(string Text)

Parameters

Text string

Debug(string, string)

Logs a debug level message

public void Debug(string EventId, string Text)

Parameters

EventId string
Text string

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

ScopeName string
ScopeParams Dictionary<string, object>

Error(Exception)

Logs an error message

public void Error(Exception Ex)

Parameters

Ex Exception

Error(string)

Logs an error message

public void Error(string Text)

Parameters

Text string

Error(string, Exception)

Logs an error message

public void Error(string EventId, Exception Ex)

Parameters

EventId string
Ex Exception

Error(string, string)

Logs an error message

public void Error(string EventId, string Text)

Parameters

EventId string
Text string

ExitScope()

Exits the last entered scope.

public void ExitScope()

Info(string)

Logs an info level message

public void Info(string Text)

Parameters

Text string

Info(string, string)

Logs an info level message

public void Info(string EventId, string Text)

Parameters

EventId string
Text string

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

EventId string
Level LogLevel
Ex Exception
Text string
Params Dictionary<string, object>

Log(string, LogLevel, string, Dictionary<string, object>)

Logs a message

public void Log(string EventId, LogLevel Level, string Text, Dictionary<string, object> Params)

Parameters

EventId string
Level LogLevel
Text string
Params Dictionary<string, object>

Log(LogLevel, Exception, string, Dictionary<string, object>)

Logs a message

public void Log(LogLevel Level, Exception Ex, string Text, Dictionary<string, object> Params)

Parameters

Level LogLevel
Ex Exception
Text string
Params Dictionary<string, object>

Log(LogLevel, string, Dictionary<string, object>)

Logs a message

public void Log(LogLevel Level, string Text, Dictionary<string, object> Params)

Parameters

Level LogLevel
Text string
Params Dictionary<string, object>

Trace(string)

Logs a trace level message

public void Trace(string Text)

Parameters

Text string

Trace(string, string)

Logs a trace level message

public void Trace(string EventId, string Text)

Parameters

EventId string
Text string

Warn(string)

Logs a warn levelmessage

public void Warn(string Text)

Parameters

Text string

Warn(string, string)

Logs a warn level message

public void Warn(string EventId, string Text)

Parameters

EventId string
Text string