Skip to content

Commit

Permalink
Try to write the logs (#241)
Browse files Browse the repository at this point in the history
* Try to write the logs

* Another creds

* Fix

* Api can write logs into elasticsearch

* Web is also put logs into elasticsearch
  • Loading branch information
framebassman authored May 13, 2024
1 parent 0bc4e19 commit 35137d7
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 274 deletions.
2 changes: 1 addition & 1 deletion .ci/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ blocks:
# - sudo snap install ngrok
# - ngrok http 80 > /dev/null &
# run migrations
- ASPNETCORE_ENVIRONMENT=TestMigrations ~/.dotnet/tools/dotnet-ef database update --project Services/TicketStore.Data/TicketStore.Data.csproj --verbose
- bash ./Scripts/wait-until-app-is-deployed.sh
- ASPNETCORE_ENVIRONMENT=TestMigrations ~/.dotnet/tools/dotnet-ef database update --project Services/TicketStore.Data/TicketStore.Data.csproj --verbose
# run integration tests
- dotnet test Services/TicketStore.Api.Tests --logger "junit;LogFilePath=TestResults/report.xml" --filter Category!=DevelopmentData
epilogue:
Expand Down
29 changes: 0 additions & 29 deletions Scripts/wait-until-app-is-deployed-copy.sh

This file was deleted.

10 changes: 4 additions & 6 deletions Services/TicketStore.Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@
"Development": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "healthcheck",
"applicationUrl": "http://localhost:3000",
"launchBrowser": false,
"applicationUrl": "http://localhost:5259",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Test": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "healthcheck",
"applicationUrl": "http://localhost:3000",
"launchBrowser": false,
"applicationUrl": "http://localhost:5259",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Test"
}
Expand Down
8 changes: 4 additions & 4 deletions Services/TicketStore.Api/TicketStore.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
<PackageReference Include="Sentry.AspNetCore" Version="4.5.0" />
<PackageReference Include="Sentry.Serilog" Version="4.5.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.4.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.2.0-dev-00752" />
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
<PackageReference Include="Serilog.Formatting.Elasticsearch" Version="10.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
<PackageReference Include="Serilog.Formatting.Elasticsearch" Version="8.4.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.4" />
<Content Include="Model\PdfDocument\Templates\Barcode.html">
Expand Down
23 changes: 0 additions & 23 deletions Services/TicketStore.Api/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,2 @@
{
"Serilog": {
"WriteTo": [
{
"Name": "Logger",
"Args": {
"configureLogger": {
"MinimumLevel": "Verbose",
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:o} {Level:u3}] ({Application}/{MachineName}/{ThreadId}) {Message}{NewLine}{Exception}",
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter,Serilog.Formatting.Compact"
}
}
]
},
"restrictedToMinimumLevel": "Verbose"
}
}
]
}
}
61 changes: 0 additions & 61 deletions Services/TicketStore.Api/appsettings.Production.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,2 @@
{
"Sentry": {
"IncludeRequestPayload": true
},
"Serilog": {
"WriteTo": [
{
"Name": "Logger",
"Args": {
"configureLogger": {
"MinimumLevel": "Verbose",
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:o} {Level:u3}] ({Application}/{MachineName}/{ThreadId}) {Message}{NewLine}{Exception}",
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter,Serilog.Formatting.Compact"
}
}
]
},
"restrictedToMinimumLevel": "Verbose"
}
},
{
"Name": "Async",
"Args": {
"configure": [
{
"Name": "File",
"Args": {
"path": "logs/root.log",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:o} [{Level:u3}] ({Application}/{MachineName}/{ThreadId}/{ThreadName}) {Message}{NewLine}{Exception}",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter,Serilog.Formatting.Compact"
}
}
]
}
},
{
"Name": "Sentry",
"Args":
{
"MinimumBreadcrumbLevel": "Debug",
"MinimumEventLevel": "Error"
}
},
{
"Name": "Elasticsearch",
"Args":
{
"nodeUris": "http://elk.chertopolokh.ru:9200",
"connectionGlobalHeaders": "Authorization=Basic ZWxhc3RpYzpwOHV3VTl5Ym40RzJKTVNI",
"indexFormat": "custom-index-{0:yyyy.MM}",
"templateName": "myCustomTemplate",
"minimumLogEventLevel": "Information"
}
}
]
}
}
39 changes: 0 additions & 39 deletions Services/TicketStore.Api/appsettings.Test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,5 @@
"FakeSender": {
"Host": "fake_sender",
"Port": 5050
},
"Serilog": {
"WriteTo": [
{
"Name": "Logger",
"Args": {
"configureLogger": {
"MinimumLevel": "Verbose",
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:o} {Level:u3}] ({Application}/{MachineName}/{ThreadId}) {Message}{NewLine}{Exception}",
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter,Serilog.Formatting.Compact"
}
}
]
},
"restrictedToMinimumLevel": "Verbose"
}
},
{
"Name": "Async",
"Args": {
"configure": [
{
"Name": "File",
"Args": {
"path": "logs/root.log",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:o} [{Level:u3}] ({Application}/{MachineName}/{ThreadId}/{ThreadName}) {Message}{NewLine}{Exception}",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter,Serilog.Formatting.Compact"
}
}
]
}
}
]
}
}
64 changes: 61 additions & 3 deletions Services/TicketStore.Api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,72 @@
"TicketStore.Api": "Verbose"
}
},
"Enrich": ["WithThreadId", "FromLogContext", "WithMachineName"],
"Enrich": ["WithThreadId", "FromLogContext", "WithMachineName", "WithEnvironmentName"],
"Properties": {
"Application": "TicketStore.Api"
}
},
"WriteTo": [
{
"Name": "Logger",
"Args": {
"configureLogger": {
"MinimumLevel": "Verbose",
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:o} {Level:u3}] ({Application}/{MachineName}/{ThreadId}) {Message}{NewLine}{Exception}",
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter,Serilog.Formatting.Compact"
}
}
]
},
"restrictedToMinimumLevel": "Verbose"
}
},
{
"Name": "Async",
"Args": {
"configure": [
{
"Name": "File",
"Args": {
"path": "logs/root.log",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:o} [{Level:u3}] ({Application}/{MachineName}/{ThreadId}/{ThreadName}) {Message}{NewLine}{Exception}",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter,Serilog.Formatting.Compact"
}
}
]
}
},
{
"Name": "Sentry",
"Args":
{
"MinimumBreadcrumbLevel": "Debug",
"MinimumEventLevel": "Error"
}
},
{
"Name": "Elasticsearch",
"Args":
{
"nodeUris": "https://kolenka-inc-4135333449.eu-central-1.bonsaisearch.net",
"indexFormat": "filebeat-7.10.2-{0:yyyy.MM.dd}",
"minimumLogEventLevel": "Information",
"connectionGlobalHeaders": "Authorization=Bearer Zm10dWNlcmMwbTpnMXpiZmJqOGx5",
"templateName": "ticketStoreTemplate",
"autoRegisterTemplate": true,
"autoRegisterTemplateVersion": "ESv7"
}
}
]
},
"Sentry": {
"Dsn": "https://[email protected]/1418218",
"IncludeRequestPayload": false
"IncludeRequestPayload": true
},
"YandexObjectStorage": {
"Protocol":"https",
Expand Down
9 changes: 4 additions & 5 deletions Services/TicketStore.Web/TicketStore.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
<PackageReference Include="Sentry.AspNetCore" Version="4.5.0" />
<PackageReference Include="Sentry.Serilog" Version="4.5.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.4.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.2.0-dev-00752" />
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
<PackageReference Include="Serilog.Formatting.Elasticsearch" Version="10.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
<PackageReference Include="Serilog.Formatting.Elasticsearch" Version="8.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
39 changes: 0 additions & 39 deletions Services/TicketStore.Web/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,2 @@
{
"Serilog": {
"WriteTo": [
{
"Name": "Logger",
"Args": {
"configureLogger": {
"MinimumLevel": "Verbose",
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:o} {Level:u3}] ({Application}/{MachineName}/{ThreadId}) {Message}{NewLine}{Exception}",
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter,Serilog.Formatting.Compact"
}
}
]
},
"restrictedToMinimumLevel": "Verbose"
}
},
{
"Name": "Async",
"Args": {
"configure": [
{
"Name": "File",
"Args": {
"path": "logs/root.log",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:o} [{Level:u3}] ({Application}/{MachineName}/{ThreadId}/{ThreadName}) {Message}{NewLine}{Exception}",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter,Serilog.Formatting.Compact"
}
}
]
}
}
]
}
}
Loading

0 comments on commit 35137d7

Please sign in to comment.