私はABPフレームワークを設定しており、ログにはSerilogを使用します。私はStartup.csに次の設定をしています。カスタムフィールドによる弾性検索のためのSerilog設定
{
"_index": "app-log-2017.12.18",
"_type": "logevent",
"_id": "******",
"_version": 1,
"_score": null,
"_source": {
"@timestamp": "2017-12-18T15:34:54.3417552+05:30",
"level": "Information",
"messageTemplate": "{HostingRequestStartingLog:l}",
"fields": {
"Protocol": "HTTP/1.1",
"Method": "GET",
"ContentType": null,
"ContentLength": null,
"Scheme": "http",
"Host": "localhost:21021",
"PathBase": "",
"Path": "/swagger/",
"QueryString": "",
"HostingRequestStartingLog": "Request starting HTTP/1.1 GET http://localhost:21021/swagger/ ",
"EventId": {
"Id": 1
},
"SourceContext": "Microsoft.AspNetCore.Hosting.Internal.WebHost",
"RequestId": "****:****",
"RequestPath": "/swhaggfgggdefrf/"
},
"renderings": {
"HostingRequestStartingLog": [
{
"Format": "l",
"Rendering": "Request starting HTTP/1.1 GET http://localhost:21021/swagger/ "
}
]
}
},
"fields": {
"@timestamp": [
1513591494341
]
},
"sort": [
1513591494341
]
}
現在、私は@timestamp、レベルとメッセージを取得しています:私は次の形式でログを取得しています。このような構成により
var logger = new LoggerConfiguration()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("https://xxxxxxxxxx.com"))
{
AutoRegisterTemplate = true,
TemplateName = "app-log",
IndexFormat = "app-log-{0:yyyy.MM.dd}",
CustomFormatter = new ElasticsearchJsonFormatter()
})
.WriteTo.File("Serilogs.txt")
.MinimumLevel.Information()
.CreateLogger();
Log.Logger = logger;
option.AddSerilog(logger);
。 Log.Logger.Information("Some Template")
を使用すると、フィールドの形式で情報を取得できます。
今、ABPフレームワークでは、各イベントのログがあります。誰もがそれらのメッセージを修正する方法を提案することはできますか? たとえば、リクエストごとにHTTP/1.1 GET http://localhost:**********のリクエストが表示され、応答ごとにのリクエストが7.8262ms 301で終了します。これらのメッセージを修正することは可能ですか?はいの場合はどうですか?
私は誰かのためにはっきりしないかもしれません。詳細な説明が必要な場合は、ご意見ください。前もって感謝します。
変更の該当する行を見ることができますか? – aaron
たとえば、MessageTemplateのフィールドを修正して、そのデータがどのログでも利用できない場合にはnullにする必要があります。等: "フィールド":{ "ElapsedMilliseconds":144.6361、 "のStatusCode":200、 "のContentType": "アプリケーション/ javascriptの"、 "HostingRequestFinishedLog": "リクエスト144.6361ms 200アプリケーション/ JavaScriptで終了します"、 "のEventId":{ "ID":2 }、 "SourceContext": "Microsoft.AspNetCore.Hosting.Internal.WebHost"、 "RequestId": "0HLAHOT40NGN8:00000006"、 "RequestPath":「/ swagger/ui/abc.js " }、 – Amrendra
nullが表示されません。 – aaron