Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Виленский Кочева #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .logs/log-20241126.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{"@t":"2024-11-26T11:36:29.9967006Z","@m":"Failed to determine the https port for redirect.","@i":"ca76cc21","@l":"Warning","@tr":"67a93e4d5449bde1dfb64d37a831b506","@sp":"5903a5fb6ba63c3a","EventId":{"Id":3,"Name":"FailedToDeterminePort"},"SourceContext":"Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware","RequestId":"0HN8E1Q8SN4E3:00000001","RequestPath":"/","ConnectionId":"0HN8E1Q8SN4E3","Environment":"Development"}
{"@t":"2024-11-26T11:36:30.8080029Z","@m":"HTTP \"GET\" \"/\" responded 200 in 292.2365 ms","@i":"62d0885c","@tr":"67a93e4d5449bde1dfb64d37a831b506","@sp":"5903a5fb6ba63c3a","RequestMethod":"GET","RequestPath":"/","StatusCode":200,"Elapsed":292.2365,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1Q8SN4E3:00000001","ConnectionId":"0HN8E1Q8SN4E3","Environment":"Development"}
{"@t":"2024-11-26T11:36:41.4626643Z","@m":"HTTP \"GET\" \"/\" responded 200 in 9.4183 ms","@i":"62d0885c","@tr":"e1940a15d832147c65c362c7fe6ce8dd","@sp":"3d600e4bb4c67e92","RequestMethod":"GET","RequestPath":"/","StatusCode":200,"Elapsed":9.4183,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1Q8SN4E3:00000005","ConnectionId":"0HN8E1Q8SN4E3","Environment":"Development"}
{"@t":"2024-11-26T11:36:42.6723254Z","@m":"HTTP \"GET\" \"/Privacy\" responded 200 in 17.8077 ms","@i":"62d0885c","@tr":"1d90775a0a97e01d2888f0f406fdb42d","@sp":"aa72f2eb9b279451","RequestMethod":"GET","RequestPath":"/Privacy","StatusCode":200,"Elapsed":17.8077,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1Q8SN4E3:00000007","ConnectionId":"0HN8E1Q8SN4E3","Environment":"Development"}
{"@t":"2024-11-26T11:36:43.0041801Z","@m":"HTTP \"GET\" \"/Privacy\" responded 200 in 2.3046 ms","@i":"62d0885c","@tr":"d56b1df684ec64f8d1dbc83733d18291","@sp":"4314126c184dfb2a","RequestMethod":"GET","RequestPath":"/Privacy","StatusCode":200,"Elapsed":2.3046,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1Q8SN4E3:00000009","ConnectionId":"0HN8E1Q8SN4E3","Environment":"Development"}
{"@t":"2024-11-26T11:36:43.6588531Z","@m":"HTTP \"GET\" \"/\" responded 200 in 1.9474 ms","@i":"62d0885c","@tr":"72ab6ae18614b7bb184b8a1845558b5e","@sp":"6b502605ce0030c1","RequestMethod":"GET","RequestPath":"/","StatusCode":200,"Elapsed":1.9474,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1Q8SN4E3:0000000B","ConnectionId":"0HN8E1Q8SN4E3","Environment":"Development"}
{"@t":"2024-11-26T11:41:58.6808298Z","@m":"Failed to determine the https port for redirect.","@i":"ca76cc21","@l":"Warning","@tr":"4e8b3d0582f37d0f83e6812bc6cd88c8","@sp":"0b851615d7586579","EventId":{"Id":3,"Name":"FailedToDeterminePort"},"SourceContext":"Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware","RequestId":"0HN8E1TAJT0TG:00000001","RequestPath":"/","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:41:58.9809606Z","@m":"Sample log. My name is \"Sh1ney\"","@i":"04820aad","@tr":"4e8b3d0582f37d0f83e6812bc6cd88c8","@sp":"0b851615d7586579","MyName":"Sh1ney","SourceContext":"telemetry.Pages.IndexModel","ActionId":"fa281058-80c0-41b2-b4b2-f5118a2d67d4","ActionName":"/Index","RequestId":"0HN8E1TAJT0TG:00000001","RequestPath":"/","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:41:59.1267869Z","@m":"HTTP \"GET\" \"/\" responded 200 in 227.3590 ms","@i":"62d0885c","@tr":"4e8b3d0582f37d0f83e6812bc6cd88c8","@sp":"0b851615d7586579","RequestMethod":"GET","RequestPath":"/","StatusCode":200,"Elapsed":227.359,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1TAJT0TG:00000001","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:00.4486182Z","@m":"HTTP \"GET\" \"/Privacy\" responded 200 in 19.9558 ms","@i":"62d0885c","@tr":"277923eb3add37b8faf08066d1b52167","@sp":"5738be550dec6ada","RequestMethod":"GET","RequestPath":"/Privacy","StatusCode":200,"Elapsed":19.9558,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1TAJT0TG:00000004","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:01.2550838Z","@m":"Sample log. My name is \"Sh1ney\"","@i":"04820aad","@tr":"09983e9609b901cd0414bf9e57553ca8","@sp":"c0cfc814cca47601","MyName":"Sh1ney","SourceContext":"telemetry.Pages.IndexModel","ActionId":"fa281058-80c0-41b2-b4b2-f5118a2d67d4","ActionName":"/Index","RequestId":"0HN8E1TAJT0TG:00000006","RequestPath":"/","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:01.2693995Z","@m":"HTTP \"GET\" \"/\" responded 200 in 15.1470 ms","@i":"62d0885c","@tr":"09983e9609b901cd0414bf9e57553ca8","@sp":"c0cfc814cca47601","RequestMethod":"GET","RequestPath":"/","StatusCode":200,"Elapsed":15.147,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1TAJT0TG:00000006","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:02.4288156Z","@m":"HTTP \"GET\" \"/Privacy\" responded 200 in 2.8047 ms","@i":"62d0885c","@tr":"7b45cbacc130952a676d87d43f7ac03a","@sp":"f66fc19e84bfca2b","RequestMethod":"GET","RequestPath":"/Privacy","StatusCode":200,"Elapsed":2.8047,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1TAJT0TG:00000008","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:02.6950795Z","@m":"HTTP \"GET\" \"/Privacy\" responded 200 in 2.0996 ms","@i":"62d0885c","@tr":"f8ed0efb163bb2a61a1db90234f6c697","@sp":"9f8a883f6847678e","RequestMethod":"GET","RequestPath":"/Privacy","StatusCode":200,"Elapsed":2.0996,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1TAJT0TG:0000000A","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:03.0209109Z","@m":"HTTP \"GET\" \"/Privacy\" responded 200 in 1.0499 ms","@i":"62d0885c","@tr":"1b271cac97ba3de1faaa1e6d6a9949d7","@sp":"d3878f9563ab6148","RequestMethod":"GET","RequestPath":"/Privacy","StatusCode":200,"Elapsed":1.0499,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1TAJT0TG:0000000C","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:03.6232994Z","@m":"Sample log. My name is \"Sh1ney\"","@i":"04820aad","@tr":"b3eaf203a1825db6b3fd329adf70c70b","@sp":"c31f899cb1f7c4fc","MyName":"Sh1ney","SourceContext":"telemetry.Pages.IndexModel","ActionId":"fa281058-80c0-41b2-b4b2-f5118a2d67d4","ActionName":"/Index","RequestId":"0HN8E1TAJT0TG:0000000E","RequestPath":"/","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:03.6380384Z","@m":"HTTP \"GET\" \"/\" responded 200 in 14.9114 ms","@i":"62d0885c","@tr":"b3eaf203a1825db6b3fd329adf70c70b","@sp":"c31f899cb1f7c4fc","RequestMethod":"GET","RequestPath":"/","StatusCode":200,"Elapsed":14.9114,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1TAJT0TG:0000000E","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:03.9451115Z","@m":"Sample log. My name is \"Sh1ney\"","@i":"04820aad","@tr":"1fe02602e482252ba999554079c9976b","@sp":"6c15a6c24afdcd16","MyName":"Sh1ney","SourceContext":"telemetry.Pages.IndexModel","ActionId":"fa281058-80c0-41b2-b4b2-f5118a2d67d4","ActionName":"/Index","RequestId":"0HN8E1TAJT0TG:00000010","RequestPath":"/","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:03.9568198Z","@m":"HTTP \"GET\" \"/\" responded 200 in 11.9627 ms","@i":"62d0885c","@tr":"1fe02602e482252ba999554079c9976b","@sp":"6c15a6c24afdcd16","RequestMethod":"GET","RequestPath":"/","StatusCode":200,"Elapsed":11.9627,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1TAJT0TG:00000010","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:04.2508822Z","@m":"Sample log. My name is \"Sh1ney\"","@i":"04820aad","@tr":"71707efff1d1177d6b532180c1c29b5f","@sp":"e5e658fb77cb1071","MyName":"Sh1ney","SourceContext":"telemetry.Pages.IndexModel","ActionId":"fa281058-80c0-41b2-b4b2-f5118a2d67d4","ActionName":"/Index","RequestId":"0HN8E1TAJT0TG:00000012","RequestPath":"/","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:04.2622210Z","@m":"HTTP \"GET\" \"/\" responded 200 in 11.4847 ms","@i":"62d0885c","@tr":"71707efff1d1177d6b532180c1c29b5f","@sp":"e5e658fb77cb1071","RequestMethod":"GET","RequestPath":"/","StatusCode":200,"Elapsed":11.4847,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1TAJT0TG:00000012","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:04.6045917Z","@m":"Sample log. My name is \"Sh1ney\"","@i":"04820aad","@tr":"f647f887b05575df2e1068788ec0d269","@sp":"3f39a6808fc41dd9","MyName":"Sh1ney","SourceContext":"telemetry.Pages.IndexModel","ActionId":"fa281058-80c0-41b2-b4b2-f5118a2d67d4","ActionName":"/Index","RequestId":"0HN8E1TAJT0TG:00000014","RequestPath":"/","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
{"@t":"2024-11-26T11:42:04.6146128Z","@m":"HTTP \"GET\" \"/\" responded 200 in 10.1823 ms","@i":"62d0885c","@tr":"f647f887b05575df2e1068788ec0d269","@sp":"3f39a6808fc41dd9","RequestMethod":"GET","RequestPath":"/","StatusCode":200,"Elapsed":10.1823,"SourceContext":"Serilog.AspNetCore.RequestLoggingMiddleware","RequestId":"0HN8E1TAJT0TG:00000014","ConnectionId":"0HN8E1TAJT0TG","Environment":"Development"}
23 changes: 23 additions & 0 deletions .logs/start-host-log-20241126.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
2024-11-26 16:36:29.996 +05:00 [WRN] Failed to determine the https port for redirect.
2024-11-26 16:36:30.808 +05:00 [INF] HTTP GET / responded 200 in 292.2365 ms
2024-11-26 16:36:41.462 +05:00 [INF] HTTP GET / responded 200 in 9.4183 ms
2024-11-26 16:36:42.672 +05:00 [INF] HTTP GET /Privacy responded 200 in 17.8077 ms
2024-11-26 16:36:43.004 +05:00 [INF] HTTP GET /Privacy responded 200 in 2.3046 ms
2024-11-26 16:36:43.658 +05:00 [INF] HTTP GET / responded 200 in 1.9474 ms
2024-11-26 16:41:58.680 +05:00 [WRN] Failed to determine the https port for redirect.
2024-11-26 16:41:58.980 +05:00 [INF] Sample log. My name is Sh1ney
2024-11-26 16:41:59.126 +05:00 [INF] HTTP GET / responded 200 in 227.3590 ms
2024-11-26 16:42:00.448 +05:00 [INF] HTTP GET /Privacy responded 200 in 19.9558 ms
2024-11-26 16:42:01.255 +05:00 [INF] Sample log. My name is Sh1ney
2024-11-26 16:42:01.269 +05:00 [INF] HTTP GET / responded 200 in 15.1470 ms
2024-11-26 16:42:02.428 +05:00 [INF] HTTP GET /Privacy responded 200 in 2.8047 ms
2024-11-26 16:42:02.695 +05:00 [INF] HTTP GET /Privacy responded 200 in 2.0996 ms
2024-11-26 16:42:03.020 +05:00 [INF] HTTP GET /Privacy responded 200 in 1.0499 ms
2024-11-26 16:42:03.623 +05:00 [INF] Sample log. My name is Sh1ney
2024-11-26 16:42:03.638 +05:00 [INF] HTTP GET / responded 200 in 14.9114 ms
2024-11-26 16:42:03.945 +05:00 [INF] Sample log. My name is Sh1ney
2024-11-26 16:42:03.956 +05:00 [INF] HTTP GET / responded 200 in 11.9627 ms
2024-11-26 16:42:04.250 +05:00 [INF] Sample log. My name is Sh1ney
2024-11-26 16:42:04.262 +05:00 [INF] HTTP GET / responded 200 in 11.4847 ms
2024-11-26 16:42:04.604 +05:00 [INF] Sample log. My name is Sh1ney
2024-11-26 16:42:04.614 +05:00 [INF] HTTP GET / responded 200 in 10.1823 ms
3 changes: 2 additions & 1 deletion Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public IndexModel(ILogger<IndexModel> logger)

public void OnGet()
{

var myName = "Sh1ney"; // ���� ���
_logger.LogInformation("Sample log. My name is {MyName}", myName);
}
}
79 changes: 63 additions & 16 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,72 @@
var builder = WebApplication.CreateBuilder(args);
using Serilog;
using Elastic.Serilog.Sinks;
using Elastic.Ingest.Elasticsearch.DataStreams;
using Elastic.Ingest.Elasticsearch;
using Elastic.Channels;
using Elastic.Transport;

// Add services to the container.
builder.Services.AddRazorPages();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())

try
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
var builder = WebApplication.CreateBuilder(args);

Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.File(".logs/start-host-log-.txt", rollingInterval: RollingInterval.Day)
.Enrich.FromLogContext()
.WriteTo.Elasticsearch([new Uri("http://localhost:9200")], opts =>
{
opts.DataStream = new DataStreamName("logs", "telemetry-logging", "demo");
opts.BootstrapMethod = BootstrapMethod.Failure;
opts.ConfigureChannel = channelOpts =>
{
channelOpts.BufferOptions = new BufferOptions
{
ExportMaxConcurrency = 10
};
};
}, transport =>
{
transport.Authentication(new BasicAuthentication("elastic", "changeme")); // Basic Auth
})
.Enrich.WithProperty("Environment", builder.Environment.EnvironmentName)
.ReadFrom.Configuration(builder.Configuration)
.CreateLogger();

builder.Host.UseSerilog();

builder.Services.AddSerilog(Log.Logger);

// Add services to the container.
builder.Services.AddRazorPages();

app.UseHttpsRedirection();
app.UseStaticFiles();
var app = builder.Build();

app.UseRouting();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseAuthorization();
app.UseHttpsRedirection();
app.UseStaticFiles();

app.MapRazorPages();
app.UseSerilogRequestLogging();

app.Run();
app.UseRouting();

app.UseAuthorization();

app.MapRazorPages();

app.Run();
}

catch (Exception ex)
{
Log.Logger.Error(ex.ToString());
}
10 changes: 1 addition & 9 deletions appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
{}
28 changes: 24 additions & 4 deletions appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
{
"Logging": {
"LogLevel": {
"Serilog": {
"WriteTo": [
{
"Name": "File",
"Args": {
"path": ".logs/log-.txt",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter, Serilog.Formatting.Compact",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true
}
},
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} {Properties:j}{NewLine}{Exception}"
}
}
],
"MinimumLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
}
},
"AllowedHosts": "*"
}
}
7 changes: 7 additions & 0 deletions telemetry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Elastic.Serilog.Sinks" Version="8.12.2" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" />
</ItemGroup>

</Project>