Log class

A basic redirectable logging system.

Remarks

The Log class provides static methods for logging messages at different levels (verbose, info, warning, error) and with context information. Context information helps identify which component generated the messages and allows for filtering of log events. In a SharePoint Framework application, these messages will appear on the developer dashboard.

Methods

error(source, error, scope)

Logs an error.

info(source, message, scope)

Logs a general informational message.

verbose(source, message, scope)

Logs a message which contains detailed information that is generally only needed for troubleshooting.

warn(source, message, scope)

Logs a warning.

Method Details

error(source, error, scope)

Logs an error.

static error(source: string, error: Error, scope?: ServiceScope): void;

Parameters

source

string

the source from where the error is logged, e.g., the class name. The source provides context information for the logged error. If the source's length is more than 20, only the first 20 characters are kept.

error

Error

the error to be logged

scope
ServiceScope

the service scope that the source uses. A service scope can provide more context information (e.g., web part information) to the logged error.

Returns

void

info(source, message, scope)

Logs a general informational message.

static info(source: string, message: string, scope?: ServiceScope): void;

Parameters

source

string

the source from where the message is logged, e.g., the class name. The source provides context information for the logged message. If the source's length is more than 20, only the first 20 characters are kept.

message

string

the message to be logged If the message's length is more than 100, only the first 100 characters are kept.

scope
ServiceScope

the service scope that the source uses. A service scope can provide more context information (e.g., web part information) to the logged message.

Returns

void

verbose(source, message, scope)

Logs a message which contains detailed information that is generally only needed for troubleshooting.

static verbose(source: string, message: string, scope?: ServiceScope): void;

Parameters

source

string

the source from where the message is logged, e.g., the class name. The source provides context information for the logged message. If the source's length is more than 20, only the first 20 characters are kept.

message

string

the message to be logged If the message's length is more than 100, only the first 100 characters are kept.

scope
ServiceScope

the service scope that the source uses. A service scope can provide more context information (e.g., web part information) to the logged message.

Returns

void

warn(source, message, scope)

Logs a warning.

static warn(source: string, message: string, scope?: ServiceScope): void;

Parameters

source

string

the source from where the message is logged, e.g., the class name. The source provides context information for the logged message. If the source's length is more than 20, only the first 20 characters are kept.

message

string

the message to be logged If the message's length is more than 100, only the first 100 characters are kept.

scope
ServiceScope

the service scope that the source uses. A service scope can provide more context information (e.g., web part information) to the logged message.

Returns

void