Skip to content

NSG.Library.Logger

Phil Huhn edited this page Apr 18, 2019 · 4 revisions

Table of Contents

Assembly: NSG.Library.Logger

Namespace: NSG.Library.Logger

The namespace contains classes for defining an interface for logging and a simple implementation of the interface.


Class: ILogData

Structure of the logging data.

Properties

Id

The id/key of the log record.

Date

The date and time of the log (now).

Application

The application passed in the constructor.

Method

The method that called log.

LogLevel

The log level, can be used to limit, depending on the implementation.

Level

The human value of the above 'LogLevel'.

UserAccount

The user identity of the caller.

Message

Log message.

Exception

The exception, including the stack trace.

Methods

ToString()

Create a 'to string'.

Return Value

formatted string of the properties.


Class: LoggingLevel

Enum of various logging levels Note: [Range(typeof(byte),]

Fields

Audit

if one would like to implement some sort of change auditing

Error

For exceptions and other errors

Warning

Warning level of logs

Info

Info level of logs

Debug

Debug level of logs

Verbose

Verbose level of logs


Class: ILogger

Interface for Logger

Methods

Log(System.Byte,System.String,System.String,System.String,System.String)

Parameters
severity

Range of byte: "0", "4" See 'LoggingLevel' enum, must be between 0 and 4

user

The user identity

method

method calling log

message

the log message

exception

the exception, including the stack trace Insert one row into Log Calling log from the web api

Return Value

the id


Log(NSG.Library.Logger.LoggingLevel,System.String,System.Reflection.MethodBase,System.String,System.Exception)

Parameters
severity

Enum of 'LoggingLevel', must be between 0 and 4




user

The user identity

method

MethodBase

message

the log message

exception

the exception, including the stack trace Insert one row into Log (Calling log from C#)

Return Value

the id


ListString(System.Int32)

Parameters
lastCount

Count of last log records to return Return a string listing.

Return Value

List of string


Class: ListLogger

A simple implementation of ILogger

Constructors

ListLogger(System.String,System.Int32)

Parameters
application

An application name for reporting the log.

max

The maximum number of logs. Default is 100 and the minimum is 10. A simple implementation of ILogger using List of Log


Methods

Log(NSG.Library.Logger.LoggingLevel,System.String,System.Reflection.MethodBase,System.String,System.Exception)

Parameters
severity

Enum of 'LoggingLevel', must be between 0 and 4

user

The user identity

method

MethodBase.GetCurrentMethod()

message

the log message

exception

the exception, including the stack trace Insert one row into Log (Calling log from C#)

Return Value

the id


Log(System.Byte,System.String,System.String,System.String,System.String)

Parameters
severity

Range of byte: "0", "4" See 'LoggingLevel' enum, must be between 0 and 4




user

The user identity

method

method calling log

message

the log message

exception

the exception, including the stack trace Insert one row into Log

            Calling log from the web api
Return Value

the id


ListString(System.Int32)

Parameters
lastCount

Count of last log records to return



Return a string listing.

Return Value

List of string


Class: Log

Make the log a singleton and globally available. Early in the application For example:

  public void Configuration(IAppBuilder app)
  {
      ...
      // Globally configure logging and replace default List-Logger
      // with SQL-Logger.
      NSG.Library.Logger.Log.Logger = new WebSrv.Models.SQLLogger(
          ApplicationDbContext.Create(),
          WebSrv.Models.Constants.ApplicationLoggerName);
  }

Properties

Logger

The globally-shared logger.

System.ArgumentNullException

Class: LogData

The Log class.

Properties

Id

The id/key of the log record.

Date

The date and time of the log (now).

Application

The application passed in the constructor.

Method

The method that called log.

LogLevel

The log level, can be used to limit, depending on the implementation.

Level

Level is the human readable value of the above 'LogLevel'.

UserAccount

The user identity of the caller.

Message

Log message.

Exception

The string value of the exception, including the stack trace.

Methods

ToString()

Formatted string value of the class properties.

Return Value

Formatted string of the properties.