Commit ca48b6e6 by Alex Nasyr

serilog for logging added

parent 066f641d
......@@ -74,8 +74,8 @@ namespace SocialMinistryDataExchange.Model {
responce_record = FormatResponce(_contingentContext, record);
}
catch (Exception ex) {
_logger.LogError($"{ex.Message}, {ex.TargetSite.Name}, {doc.Person}");
_logger.LogInformation($"creating empty person for doc.seria={doc.Person.PersonDocumentSeria}; doc.number={doc.Person.PersonDocumentNumber}");
_logger.LogError($"{ex.Message}, {ex.TargetSite.Name}");
_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 });
}
......
......@@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.9" />
......
......@@ -4,9 +4,12 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using SocialMinistryDataExchange.Model;
using SocialMinistryDataExchange.Model.DB.Center;
using System;
using System.IO;
namespace SocialMinistryDataExchange {
public class Startup {
......@@ -31,7 +34,7 @@ namespace SocialMinistryDataExchange {
}
// 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()) {
app.UseDeveloperExceptionPage();
app.UseSwagger();
......@@ -47,6 +50,8 @@ namespace SocialMinistryDataExchange {
app.UseEndpoints(endpoints => {
endpoints.MapControllers();
});
loggerFactory.AddFile($@"{Directory.GetCurrentDirectory()}\Logs\{DateTime.Now.ToString("yyyy-MM-dd")}.log");
}
}
}
......@@ -2,8 +2,8 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
//"Microsoft": "Warning",
//"Microsoft.Hosting.Lifetime": "Information"
}
},
"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