ILoggerService
Last updated
Last updated
The service defines a contract for logging functionalities, supporting logging of messages with a specified trace level and optional formatting arguments.
Wisej.AI employs the ILoggerService
to log a variety of events and information. The default implementation directly utilizes the System.Diagnostics.Trace
class. However, you have the flexibility to implement your own logging service, allowing you to integrate any logging library of your choice.
To implement logging in Wisej.AI, you need to work with two primary methods: Log(TraceLevel level, string message, params object[] arguments)
and Log(TraceLevel level, Exception exception)
.
The Log(TraceLevel level, string message, params object[] arguments)
method enables you to log messages that can include .NET formatting placeholders, along with any number of replacement values. This is particularly useful for creating dynamic and informative log entries.
On the other hand, the Log(TraceLevel level, Exception exception)
method is specifically designed to log exceptions. This method allows you to capture and record exception details.
Utilize the TraceLevel
to decide whether, how, and where a message should be logged. The default implementation serves as a straightforward bridge to the Trace
class:
As an alternative to registering your own ILoggerService
, you can register a TraceListener
with the System.Diagnostics.Trace.Listeners
collection. For instance, you can use as an example to direct log output to NLog, enabling advanced logging features and configurations without the need to implement a custom logging service.
In Wisej.AI, the default logging mechanism is implemented within the . This service utilizes the .NET class to record and log all messages generated by Wisej.AI components.
You have the flexibility to either implement your own version of ILoggerService
or enhance logging functionality by adding custom trace listeners to . By creating a custom implementation of ILoggerService
, you can tailor the logging process to suit specific requirements or use different logging frameworks. Alternatively, by adding custom trace listeners, you can extend the default logging behavior to capture log entries in various formats or direct them to specific outputs, such as files, event logs, or external monitoring systems.