Class FluentLogger
Default FluentResults.IResultLogger: writes the outcome of a FluentResults.ResultBase to an ILogger<TCategoryName> using the Arc4u business logging conventions.
[Export(typeof(IResultLogger))]
[Shared]
public class FluentLogger : IResultLogger
- Inheritance
-
FluentLogger
- Implements
-
IResultLogger
- Inherited Members
Remarks
Registered as a shared (singleton) service through the Export attribute. For a failed result each error is logged
on its own: a ValidationError at the level matching its Severity (with its code as a property when set),
an exceptional error as an exception, any other error (a ProblemDetailError for example) at the level requested by the caller
(the logLevel of LogIfFailed). The informational reasons of the result are then logged once.
Use AddResultLogger(IServiceCollection) to register it and hand it to Result.Setup.
Constructors
FluentLogger(ILogger<FluentLogger>)
Creates a logger writing to the given logger.
public FluentLogger(ILogger<FluentLogger> logger)
Parameters
loggerILogger<FluentLogger>The logger receiving the business messages.
Methods
Log(string, string, ResultBase, LogLevel)
Log result information
public void Log(string context, string content, ResultBase result, LogLevel logLevel)
Parameters
contextstringAdditional log context
contentstringContent to log
resultResultBaseThe result to log
logLevelLogLevelThe LogLevel
Log<TContext>(string, ResultBase, LogLevel)
Log result information
public void Log<TContext>(string content, ResultBase result, LogLevel logLevel)
Parameters
Type Parameters
TContextAdditional log context