The ILogger interface exposes the methods listed in the following table:
Methods | Description |
---|---|
Logs the supplied message by using a “Debug” level scope. | |
Logs the contents of a specified DataModel instance. | |
Logs the contents in a list of strings. | |
Logs the supplied exception by using an “Error” level scope. | |
Logs the supplied message by using an “Error” level scope. | |
Logs the supplied message by using an “Information” level scope. |
The LogDebug method (Func<String>) logs the supplied message by using a Debug level scope.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
void LogDebug(
Func<string> action
)
Argument
action – System.Func<String>
This argument provides a delegate to a function that defines and optionally formats the message to be written to the log file.
The LogDebug method (String, Func<Object>) logs the contents of a specified DataModel instance.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
void LogDebug( string prefix, Func<Object> action )
Arguments
prefix – System.String
This argument provides a prefix string to be displayed in the log file.
action – System.Func<Object>
This argument provides the DataModel object to be logged.
The LogDebugList method logs the contents in a list of string.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
void LogDebugList( string prefix Func<IEnumerable<string>> action )
Argument
prefix – System.String
This argument provides a prefix string to be displayed in the log file.
action – System.Func<Exception>
This argument provides the string items.
The LogError method (Func<Exception>) logs the supplied message by using an Error level scope.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
void LogError(
Func<Exception> action
)
Argument
action – System.Func<Exception>
This argument provides the exception to be written to the log file.
The LogError method (Func<String>) logs the supplied message by using an Error level scope.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
void LogError(
Func<string> action
)
Argument
action – System.Func<String>
This argument provides a delegate to a function to write the message to the log file.
The LogInfo method logs the supplied message by using an Information level scope.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
void LogInfo(
Func<string> action
)
Argument
action – Func<string>
This argument provides a delegate to a function that defines and optionally formats the message to be written to the log file.
Using the ILogger Interface for the LogInfo, LogDebug, and LogError Methods
The following code is an example of using the various Logging methods supported by the ILogger interface:
// Create a new connection to the AB Suite host system // Use the Access Layer API ConnectionFactory to create an instance of a Connection Interface class // The Create method also allows you to initialize the Access Layer API Logging level and location. ABSConnection = ConnectionFactory.Create(new Sample.Custom.DataModels.Core.IspecFactory(), level: "DEBUG", logPath: @"C:\Temp\MVC"); // Get the Logger object from the IConnection interface ApplicationLogger = ABSConnection.Logger; // Log an information message ApplicationLogger.LogInfo(() => "<Client>:: Log Information message."); // Log a Debug message ApplicationLogger.LogDebug(() => string.Format("<Client>:: Log Debug message.")); // Log an Error message ApplicationLogger.LogError(() => string.Format("<Client>:: Log Error message!"));