Skip to content

Commit 50f6cfa

Browse files
adding docs info
removing unused code
1 parent 657162f commit 50f6cfa

File tree

3 files changed

+9
-59
lines changed

3 files changed

+9
-59
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# serilog-ui
2-
A simple log viewer to see logs saved by [Serilog.Sinks.MSSqlServer](https://github.com/serilog/serilog-sinks-mssqlserver), [Serilog.Sinks.Postgresql](https://github.com/b00ted/serilog-sinks-postgresql) and [Serilog.Sinks.MongoDB](https://github.com/serilog/serilog-sinks-mongodb) (other sinks will be added in the future).
2+
A simple log viewer to see logs saved by [Serilog.Sinks.MSSqlServer](https://github.com/serilog/serilog-sinks-mssqlserver), [Serilog.Sinks.Postgresql](https://github.com/b00ted/serilog-sinks-postgresql), [Serilog.Sinks.MongoDB](https://github.com/serilog/serilog-sinks-mongodb) and [Serilog.Sinks.ElasticSearch](https://github.com/serilog/serilog-sinks-elasticsearch) (other sinks will be added in the future).
33

44
![serilog ui](https://raw.githubusercontent.com/mo-esmp/serilog-ui/master/assets/serilog-ui.jpg)
55

@@ -26,6 +26,12 @@ of _Serilog.UI.MongoDbProvider_ [Nuget package](https://www.nuget.org/packages/S
2626
Install-Package Serilog.UI.MongoDbProvider
2727
```
2828

29+
of _Serilog.UI.ElasticSearchDbProvider_ [Nuget package](https://www.nuget.org/packages/Serilog.Ui.ElasticSearchDbProvider):
30+
31+
```powershell
32+
Install-Package Serilog.UI.ElasticSearchDbProvider
33+
```
34+
2935
Then, add `AddSerilogUi()` to `IServiceCollection` in `Startup.ConfigureServices` method:
3036

3137
```csharp
@@ -37,6 +43,8 @@ public void ConfigureServices(IServiceCollection services)
3743
// services.AddSerilogUi(options => options.UseNpgSql("ConnectionString", "LogTableName"));
3844
// or
3945
// services.AddSerilogUi(options => options.UseMongoDb("ConnectionString", "DatabaseName", "CollectionName"))
46+
// or
47+
// services.AddSerilogUi(options => options.UseElasticSearchDb(endpoint: new System.Uri("http://localhost:9200"), indexName: "logging-index"))
4048
}
4149
```
4250

samples/SampleWebApp/Startup.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public void ConfigureServices(IServiceCollection services)
4545
authOption.AuthenticationType = AuthenticationType.Jwt;
4646
authOption.Usernames = new[] { "[email protected]" };
4747
})
48-
//.UseElasticSearchDb(new System.Uri("http://localhost:9200"), "logging-index")
4948
.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), "Logs"));
5049

5150
services.AddSwaggerGen();

src/Serilog.Ui.ElasticSearchProvider/Extensions/SerilogUiOptionBuilderExtensions.cs

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using Elasticsearch.Net;
22
using Microsoft.Extensions.DependencyInjection;
33
using Nest;
4-
using Nest.JsonNetSerializer;
54
using Newtonsoft.Json;
6-
using Newtonsoft.Json.Serialization;
75
using Serilog.Ui.Core;
86
using System;
97
using System.IO;
@@ -31,51 +29,13 @@ public static void UseElasticSearchDb(this SerilogUiOptionsBuilder optionsBuilde
3129
builder.Services.AddSingleton(options);
3230

3331
var pool = new SingleNodeConnectionPool(endpoint);
34-
//var connectionSettings1 = new ConnectionSettings(pool, sourceSerializer: JsonNetSerializer.Default);
35-
//var connectionSettings = new ConnectionSettings(pool, sourceSerializer: (builtin, values) => new CamelCaseJsonNetSerializer(builtin, values));
3632
var connectionSettings = new ConnectionSettings(pool, sourceSerializer: (builtin, values) => new VanillaSerializer());
3733

38-
//var connectionSettings = new ConnectionSettings(pool, (builtin, settings) =>
39-
// new JsonNetSerializer(builtin, settings,
40-
// modifyContractResolver: c => { c.NamingStrategy = new SnakeCaseNamingStrategy(); }
41-
// )
42-
//);
43-
44-
4534
builder.Services.AddSingleton<IElasticClient>(o => new ElasticClient(connectionSettings));
4635
builder.Services.AddScoped<IDataProvider, ElasticSearchDbDataProvider>();
4736
}
4837
}
4938

50-
class CamelCaseJsonNetSerializer : ConnectionSettingsAwareSerializerBase
51-
{
52-
public CamelCaseJsonNetSerializer(IElasticsearchSerializer builtinSerializer, IConnectionSettingsValues connectionSettings)
53-
: base(builtinSerializer, connectionSettings) { }
54-
55-
protected override void ModifyContractResolver(ConnectionSettingsAwareContractResolver resolver) =>
56-
resolver.NamingStrategy = new CamelCaseNamingStrategy();
57-
58-
public override Task<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default)
59-
{
60-
using (StreamReader reader = new StreamReader(stream))
61-
using (JsonTextReader jsonReader = new JsonTextReader(reader))
62-
{
63-
JsonSerializer ser = new JsonSerializer();
64-
return Task.FromResult(ser.Deserialize<T>(jsonReader));
65-
}
66-
}
67-
68-
public override Task<object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default)
69-
{
70-
using (StreamReader reader = new StreamReader(stream))
71-
using (JsonTextReader jsonReader = new JsonTextReader(reader))
72-
{
73-
JsonSerializer ser = new JsonSerializer();
74-
return Task.FromResult(ser.Deserialize(jsonReader, type));
75-
}
76-
}
77-
}
78-
7939
public class VanillaSerializer : IElasticsearchSerializer
8040
{
8141
public T Deserialize<T>(Stream stream)
@@ -84,29 +44,12 @@ public T Deserialize<T>(Stream stream)
8444

8545
public object Deserialize(Type type, Stream stream)
8646
{
87-
#if DEBUG
88-
var memStream = new MemoryStream();
89-
stream.CopyTo(memStream);
90-
memStream.Seek(0, SeekOrigin.Begin);
91-
92-
var reader = new StreamReader(memStream);
93-
var @string = reader.ReadToEnd();
94-
95-
memStream.Seek(0, SeekOrigin.Begin);
96-
97-
using (var jreader = new JsonTextReader(reader))
98-
{
99-
var serializer = new JsonSerializer();
100-
return serializer.Deserialize(jreader, type);
101-
}
102-
#else
10347
var reader = new StreamReader(stream);
10448
using (var jreader = new JsonTextReader(reader))
10549
{
10650
var serializer = new JsonSerializer();
10751
return serializer.Deserialize(jreader, type);
10852
}
109-
#endif
11053
}
11154

11255
public Task<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default(CancellationToken)) =>

0 commit comments

Comments
 (0)