Class LoggingComponentRenderer

Version: 21.x

An IComponentRenderer that writes to a specified log instead of generating HTML output.

Inheritance
System.Object
LoggingComponentRenderer
Implements
Namespace: Sitecore.AspNet.RenderingEngine.Rendering
Assembly: Sitecore.AspNet.RenderingEngine.dll
Syntax
RequestResponse
public class LoggingComponentRenderer : Object, IComponentRenderer

Constructors

LoggingComponentRenderer(ILogger<LoggingComponentRenderer>)

Initializes a new instance of the LoggingComponentRenderer class.

Declaration
RequestResponse
public LoggingComponentRenderer(ILogger<LoggingComponentRenderer> logger)
Parameters
TypeNameDescription
Microsoft.Extensions.Logging.ILogger<LoggingComponentRenderer>logger

The Microsoft.Extensions.Logging.ILogger to use for logging.

Methods

Describe(Predicate<String>)

Creates an instance of a ComponentRendererDescriptor for the LoggingComponentRenderer class.

Declaration
RequestResponse
public static ComponentRendererDescriptor Describe(Predicate<string> match)
Parameters
TypeNameDescription
System.Predicate<System.String>match

A predicate to use when attempting to match a layout component.

Returns
TypeDescription
ComponentRendererDescriptor

An instance of ComponentRendererDescriptor that describes the LoggingComponentRenderer.

Render(ISitecoreRenderingContext, ViewContext)

Generates the output HTML.

Declaration
RequestResponse
public Task<IHtmlContent> Render(ISitecoreRenderingContext renderingContext, ViewContext viewContext)
Parameters
TypeNameDescription
ISitecoreRenderingContextrenderingContext

The current ISitecoreRenderingContext.

Microsoft.AspNetCore.Mvc.Rendering.ViewContextviewContext

The current Microsoft.AspNetCore.Mvc.Rendering.ViewContext.

Returns
TypeDescription
System.Threading.Tasks.Task<Microsoft.AspNetCore.Html.IHtmlContent>

The HTML content to render.

Implements

Do you have some feedback for us?

If you have suggestions for improving this article,