Show / Hide Table of Contents

Logging ZptSharp operations

ZptSharp integrates with the Microsoft.Extensions.Logging framework. By default it is configured to use a null/no-operation logger.

When configuring services in dependency injection, if you add a logger implementation then you may receive ZptSharp log messages. Messages generated by ZptSharp are generally recorded at Debug and Trace levels.

Example

Here is a very simple example which activates console logging with dependency injection. As you can see, the addition of logging is not linked intrinsically to ZptSharp itself.

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using ZptSharp;

serviceCollection
    .AddZptSharp()
    .AddStandardZptExpressions()
    .AddHapZptDocuments();

serviceCollection
    .AddLogging(b => {
        b.ClearProviders();
        b.AddSimpleConsole(o => {
            o.ColorBehavior = LoggerColorBehavior.Disabled;
            o.IncludeScopes = true;
        });
        b.SetMinimumLevel(LogLevel.Debug);
    });
  • Improve this Doc
In This Article
Back to top Generated by DocFX