Skip to content
Matteo Gregoricchio edited this page May 7, 2024 · 11 revisions

Reference namespace: Serilog.Ui.Core

API

IDataProvider interface

// the Provider unique name
string Name { get; }

// Fetch the data and returns a Tuple, consisting of
// - an IEnumerable of LogModel
// - the total number of matches obtained with the non-paginated query.
Task<(IEnumerable<LogModel> results, int total)> FetchDataAsync(
  FetchLogsQuery queryParams,
  CancellationToken cancellationToken = default);

Authentication

IUiAuthorizationFilter interface

/// <summary>
/// Authorizes a synchronous request.
/// </summary>
bool Authorize();

IUiAsyncAuthorizationFilter interface

/// <summary>
/// Authorizes an asynchronous request.
/// </summary>
Task<bool> AuthorizeAsync();

Note: DI Registration

To register any custom implementation in the .NET IServiceProvider, Serilog UI exposes a series of extensions methods you can use.

Models

FetchLogsQuery class

// the unique provider name to run the query on
string DatabaseKey
// the 0-based page (used by the providers)
int Page
// the actual page (used by the client-app) [Linq.Skip]
int CurrentPage
// the amount of results to retrieve in a single request [Linq.Take]
int Count
// a log level filter
string Level
// a text search
string SearchCriteria
DateTime? StartDate
DateTime? EndDate
SearchOptions.SortProperty SortOn = SearchOptions.SortProperty.Timestamp;
SearchOptions.SortDirection SortBy = SearchOptions.SortDirection.Desc;

LogModel class

virtual int RowNo { private set; }
virtual string Level
virtual string Message
virtual DateTime Timestamp
virtual string Exception
virtual string Properties
virtual string PropertyType

// use to set the RowNo; 
// rowNoStart should be {FetchLogsQuery}.Count * {FetchLogsQuery}.Page
LogModel SetRowNo(int rowNoStart, int index)

Write a custom implementation

Implement a custom provider

to disable sort

to register a provider with additional columns:

Implement a custom authorization filter

Clone this wiki locally