Skip to content

Commit 243625f

Browse files
authored
Update reamdme file.
1 parent 5ffd250 commit 243625f

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,48 @@
11
# serilog-ui
2-
Simple web UI for several Serilog sinks.
2+
A simple log viewer to see logs saved by [Serilog.Sinks.MSSqlServer](https://github.com/serilog/serilog-sinks-mssqlserver).
3+
4+
![serilog ui](https://raw.githubusercontent.com/mo-esmp/serilog-ui/master/assets/serilog-ui.jpg)
5+
6+
Install the _Serilog.UI_ [NuGet package](https://www.nuget.org/packages/Serilog.UI) and _Serilog.Ui.MsSqlServerProvider_ [NuGet package](https://www.nuget.org/packages/Serilog.Ui.MsSqlServerProvider)
7+
8+
```powershell
9+
Install-Package Serilog.UI
10+
Install-Package Serilog.UI.MsSqlServerProvider
11+
```
12+
or
13+
```shell
14+
dotnet add package Serilog.UI
15+
dotnet add package Serilog.UI.MsSqlServerProvider
16+
```
17+
18+
**Then**, add `UseSerilogUi()` to `IServiceCollection` in `ConfigureServices` method:
19+
20+
```csharp
21+
public void ConfigureServices(IServiceCollection services)
22+
{
23+
var mvcBuilder = services.AddControllersWithViews();
24+
services.AddSerilogUi(mvcBuilder, options => options.UseSqlServer("ConnectionString", "Logs"));
25+
.
26+
.
27+
.
28+
```
29+
30+
You can also secure log viewer by allwoing specific users or roles to view logs:
31+
```csharp
32+
public void ConfigureServices(IServiceCollection services)
33+
{
34+
var mvcBuilder = services.AddControllersWithViews();
35+
services.AddSerilogUi(mvcBuilder, options => options
36+
.EnableAuthorization(authOptions =>
37+
{
38+
authOptions.Usernames = new[] { "User1", "User2" };
39+
authOptions.Roles = new[] { "AdminRole" };
40+
})
41+
.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), "Logs"));
42+
.
43+
.
44+
.
45+
```
46+
Only `User1` and `User2` or users with `AdminRole` role can view logs.
47+
48+

0 commit comments

Comments
 (0)