Commit ca48b6e6 by Alex Nasyr

serilog for logging added

parent 066f641d
...@@ -74,8 +74,8 @@ namespace SocialMinistryDataExchange.Model { ...@@ -74,8 +74,8 @@ namespace SocialMinistryDataExchange.Model {
responce_record = FormatResponce(_contingentContext, record); responce_record = FormatResponce(_contingentContext, record);
} }
catch (Exception ex) { catch (Exception ex) {
_logger.LogError($"{ex.Message}, {ex.TargetSite.Name}, {doc.Person}"); _logger.LogError($"{ex.Message}, {ex.TargetSite.Name}");
_logger.LogInformation($"creating empty person for doc.seria={doc.Person.PersonDocumentSeria}; doc.number={doc.Person.PersonDocumentNumber}"); _logger.LogInformation($"Creating empty person for doc.seria={doc.Person.PersonDocumentSeria}; doc.number={doc.Person.PersonDocumentNumber}");
responce_record = FormatResponce(_contingentContext, new SMResponceTemp() { rowguid_eais = doc.Person.rowguid_eais, СерияДокумента = doc.Person.PersonDocumentSeria, НомерДокумента = doc.Person.PersonDocumentNumber }); responce_record = FormatResponce(_contingentContext, new SMResponceTemp() { rowguid_eais = doc.Person.rowguid_eais, СерияДокумента = doc.Person.PersonDocumentSeria, НомерДокумента = doc.Person.PersonDocumentNumber });
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.9" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.9" />
......
...@@ -4,9 +4,12 @@ using Microsoft.EntityFrameworkCore; ...@@ -4,9 +4,12 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using SocialMinistryDataExchange.Model; using SocialMinistryDataExchange.Model;
using SocialMinistryDataExchange.Model.DB.Center; using SocialMinistryDataExchange.Model.DB.Center;
using System;
using System.IO;
namespace SocialMinistryDataExchange { namespace SocialMinistryDataExchange {
public class Startup { public class Startup {
...@@ -31,7 +34,7 @@ namespace SocialMinistryDataExchange { ...@@ -31,7 +34,7 @@ namespace SocialMinistryDataExchange {
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) {
if (env.IsDevelopment()) { if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
app.UseSwagger(); app.UseSwagger();
...@@ -47,6 +50,8 @@ namespace SocialMinistryDataExchange { ...@@ -47,6 +50,8 @@ namespace SocialMinistryDataExchange {
app.UseEndpoints(endpoints => { app.UseEndpoints(endpoints => {
endpoints.MapControllers(); endpoints.MapControllers();
}); });
loggerFactory.AddFile($@"{Directory.GetCurrentDirectory()}\Logs\{DateTime.Now.ToString("yyyy-MM-dd")}.log");
} }
} }
} }
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft": "Warning", //"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information" //"Microsoft.Hosting.Lifetime": "Information"
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment