refactor: Entfernen des App Loggers und Implementierung des ILogger-Interfaces; Konfiguration der API für NLog
- App Logger entfernt und durch die Implementierung des `ILogger`-Interfaces ersetzt, um eine konsistente Logging-Architektur zu gewährleisten. - API für die Nutzung von NLog konfiguriert, um eine leistungsstarke und flexible Logging-Lösung bereitzustellen. - Konfigurationsdateien und Setup-Anpassungen für die Integration von NLog in die API vorgenommen.
This commit is contained in:
parent
cfd163a7a7
commit
197db1e08b
@ -1,11 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class AdWebAppToWebAppRoleRepository : BaseRepository<AdWebAppToWebAppRole>
|
||||
{
|
||||
public AdWebAppToWebAppRoleRepository(WebApiContext context) : base(context)
|
||||
public AdWebAppToWebAppRoleRepository(WebApiContext context, ILogger<AdWebAppToWebAppRoleRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class CostCentreRepository : BaseRepository<CostCentre>
|
||||
{
|
||||
public CostCentreRepository(WebApiContext context) : base(context)
|
||||
public CostCentreRepository(WebApiContext context, ILogger<CostCentreRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class DepartmentRepository : BaseRepository<Department>
|
||||
{
|
||||
public DepartmentRepository(WebApiContext context) : base(context)
|
||||
public DepartmentRepository(WebApiContext context, ILogger<DepartmentRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class DepartmentToWebAppToEmployeeForWindreamRepository : BaseRepository<DepartmentToWebAppToEmployeeForWindream>
|
||||
{
|
||||
public DepartmentToWebAppToEmployeeForWindreamRepository(WebApiContext context) : base(context)
|
||||
public DepartmentToWebAppToEmployeeForWindreamRepository(WebApiContext context, ILogger<DepartmentToWebAppToEmployeeForWindreamRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class DocumentArtRepository : BaseRepository<DocumentArt>
|
||||
{
|
||||
public DocumentArtRepository(WebApiContext context) : base(context)
|
||||
public DocumentArtRepository(WebApiContext context, ILogger<DocumentArtRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class DocumentArtToDepartmentRepository : BaseRepository<DocumentArtToDepartment>
|
||||
{
|
||||
public DocumentArtToDepartmentRepository(WebApiContext context) : base(context)
|
||||
public DocumentArtToDepartmentRepository(WebApiContext context, ILogger<DocumentArtToDepartmentRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeAttributeRepository : BaseRepository<EmployeeAttribute>
|
||||
{
|
||||
public EmployeeAttributeRepository(WebApiContext context) : base(context)
|
||||
public EmployeeAttributeRepository(WebApiContext context, ILogger<EmployeeAttributeRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeRepository : BaseRepository<Employee>
|
||||
{
|
||||
public EmployeeRepository(WebApiContext context) : base(context)
|
||||
public EmployeeRepository(WebApiContext context, ILogger<EmployeeAttributeRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeStatusRepository : BaseRepository<EmployeeStatus>
|
||||
{
|
||||
public EmployeeStatusRepository(WebApiContext context) : base(context)
|
||||
public EmployeeStatusRepository(WebApiContext context, ILogger<EmployeeStatusRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeToAttributeRepository : BaseRepository<EmployeeToAttribute>
|
||||
{
|
||||
public EmployeeToAttributeRepository(WebApiContext context) : base(context)
|
||||
public EmployeeToAttributeRepository(WebApiContext context, ILogger<EmployeeToAttributeRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class EmployeeToDepartmentRepository : BaseRepository<EmployeeToDepartment>
|
||||
{
|
||||
public EmployeeToDepartmentRepository(WebApiContext context) : base(context)
|
||||
public EmployeeToDepartmentRepository(WebApiContext context, ILogger<EmployeeToDepartmentRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ using DAL.Models.Filters;
|
||||
using HRD.LDAPService;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -14,7 +15,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
private readonly LdapManager _ldapManager;
|
||||
|
||||
public EmployeeToWebAppRepository(WebApiContext context, LdapManager ldapManager) : base(context)
|
||||
public EmployeeToWebAppRepository(WebApiContext context, LdapManager ldapManager, ILogger<EmployeeToWebAppRepository> logger) : base(context, logger)
|
||||
{
|
||||
_ldapManager = ldapManager;
|
||||
}
|
||||
@ -107,7 +108,7 @@ namespace DAL.Repositories
|
||||
|
||||
if (!result)
|
||||
{
|
||||
WriteLogError($"An error occurred while '{action}' the '{employee.LoginName}' into '{groupSuffix}'.");
|
||||
_logger.LogError($"An error occurred while '{action}' the '{employee.LoginName}' into '{groupSuffix}'.");
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class ProjectRepository : BaseRepository<Project>
|
||||
{
|
||||
public ProjectRepository(WebApiContext context) : base(context)
|
||||
public ProjectRepository(WebApiContext context, ILogger<ProjectRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class RangRepository : BaseRepository<Rang>
|
||||
{
|
||||
public RangRepository(WebApiContext context) : base(context)
|
||||
public RangRepository(WebApiContext context, ILogger<RangRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class SubsidiaryRepository : BaseRepository<Subsidiary>
|
||||
{
|
||||
public SubsidiaryRepository(WebApiContext context) : base(context)
|
||||
public SubsidiaryRepository(WebApiContext context, ILogger<SubsidiaryRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppAdditionalRoleRepository : BaseRepository<WebAppAdditionalRole>
|
||||
{
|
||||
public WebAppAdditionalRoleRepository(WebApiContext context) : base(context)
|
||||
public WebAppAdditionalRoleRepository(WebApiContext context, ILogger<WebAppAdditionalRoleRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppRepository : BaseRepository<WebApp>
|
||||
{
|
||||
public WebAppRepository(WebApiContext context) : base(context)
|
||||
public WebAppRepository(WebApiContext context, ILogger<WebAppRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using DAL.Models.Entities;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppRoleRepository : BaseRepository<WebAppRole>
|
||||
{
|
||||
public WebAppRoleRepository(WebApiContext context) : base(context)
|
||||
public WebAppRoleRepository(WebApiContext context, ILogger<WebAppRoleRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ using DAL.Models.Filters;
|
||||
using HRD.LDAPService;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -14,7 +15,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
private readonly LdapManager _ldapManager;
|
||||
|
||||
public WebAppToDepartmentRepository(WebApiContext context, LdapManager ldapManager) : base(context)
|
||||
public WebAppToDepartmentRepository(WebApiContext context, LdapManager ldapManager, ILogger<WebAppToDepartmentRepository> logger) : base(context, logger)
|
||||
{
|
||||
_ldapManager = ldapManager;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ using DAL.Models.Filters;
|
||||
using HRD.LDAPService;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -14,7 +15,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
private readonly LdapManager _ldapManager;
|
||||
|
||||
public WebAppToWebAppAdditionalRoleRepository(WebApiContext context, LdapManager ldapManager) : base(context)
|
||||
public WebAppToWebAppAdditionalRoleRepository(WebApiContext context, LdapManager ldapManager, ILogger<WebAppToWebAppAdditionalRoleRepository> logger) : base(context, logger)
|
||||
{
|
||||
_ldapManager = ldapManager;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WebAppToWebAppRoleRepository : BaseRepository<WebAppToWebAppRole>
|
||||
{
|
||||
public WebAppToWebAppRoleRepository(WebApiContext context) : base(context)
|
||||
public WebAppToWebAppRoleRepository(WebApiContext context, ILogger<WebAppToWebAppRoleRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamColumnsToDepartmentRepository : BaseRepository<WindreamColumnsToDepartment>
|
||||
{
|
||||
public WindreamColumnsToDepartmentRepository(WebApiContext context) : base(context)
|
||||
public WindreamColumnsToDepartmentRepository(WebApiContext context, ILogger<WindreamColumnsToDepartmentRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamIndexRepository : BaseRepository<WindreamIndex>
|
||||
{
|
||||
public WindreamIndexRepository(WebApiContext context) : base(context)
|
||||
public WindreamIndexRepository(WebApiContext context, ILogger<WindreamIndexRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamIndexToWindreamSearchToDepartmentRepository : BaseRepository<WindreamIndexToWindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamIndexToWindreamSearchToDepartmentRepository(WebApiContext context) : base(context)
|
||||
public WindreamIndexToWindreamSearchToDepartmentRepository(WebApiContext context, ILogger<WindreamIndexToWindreamSearchToDepartmentRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamInputFolderRepository : BaseRepository<WindreamInputFolder>
|
||||
{
|
||||
public WindreamInputFolderRepository(WebApiContext context) : base(context)
|
||||
public WindreamInputFolderRepository(WebApiContext context, ILogger<WindreamInputFolderRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchItemRepository : BaseRepository<WindreamSearchItem>
|
||||
{
|
||||
public WindreamSearchItemRepository(WebApiContext context) : base(context)
|
||||
public WindreamSearchItemRepository(WebApiContext context, ILogger<WindreamSearchItemRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchItemToWindreamSearchToDepartmentRepository : BaseRepository<WindreamSearchItemToWindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamSearchItemToWindreamSearchToDepartmentRepository(WebApiContext context) : base(context)
|
||||
public WindreamSearchItemToWindreamSearchToDepartmentRepository(WebApiContext context, ILogger<WindreamSearchItemToWindreamSearchToDepartmentRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchRepository : BaseRepository<WindreamSearch>
|
||||
{
|
||||
public WindreamSearchRepository(WebApiContext context) : base(context)
|
||||
public WindreamSearchRepository(WebApiContext context, ILogger<WindreamSearchRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ using DAL.Models.Entities;
|
||||
using DAL.Models.Filters;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,7 +11,7 @@ namespace DAL.Repositories
|
||||
{
|
||||
public class WindreamSearchToDepartmentRepository : BaseRepository<WindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamSearchToDepartmentRepository(WebApiContext context) : base(context)
|
||||
public WindreamSearchToDepartmentRepository(WebApiContext context, ILogger<WindreamSearchToDepartmentRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using HRD.LDAPService;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -11,7 +12,7 @@ namespace DAL._Shared.SharedRepositories
|
||||
public class WebAppEmployeeInfoRepository : BaseRepository<WebAppEmployeeInfo>
|
||||
|
||||
{
|
||||
public WebAppEmployeeInfoRepository(WebApiContext context) : base(context)
|
||||
public WebAppEmployeeInfoRepository(WebApiContext context, ILogger<WebAppEmployeeInfoRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using DAL._Shared.SharedModels;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DAL._Shared.SharedRepositories
|
||||
{
|
||||
public class WebAppUserRepository : BaseRepository<WebAppUser>
|
||||
{
|
||||
public WebAppUserRepository(WebApiContext context) : base(context)
|
||||
public WebAppUserRepository(WebApiContext context, ILogger<WebAppUserRepository> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,255 +0,0 @@
|
||||
using HRD.AppLogger;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace HRD.AppLogger
|
||||
{
|
||||
public enum EN_LoggingLevel
|
||||
{
|
||||
Trace = 1,
|
||||
Debug = 2,
|
||||
Info = 3,
|
||||
Warn = 4,
|
||||
Error = 5,
|
||||
Fatal = 6,
|
||||
Off = 7
|
||||
}
|
||||
}
|
||||
|
||||
public static class AppLoggerConfig
|
||||
{
|
||||
private static readonly string DBLOG_CommandText =
|
||||
@"
|
||||
INSERT INTO dbo.DBLog
|
||||
( MachineName,
|
||||
Application,
|
||||
Logged,
|
||||
Level,
|
||||
Message,
|
||||
Logger,
|
||||
CallSite,
|
||||
Webrequest,
|
||||
Stacktrace,
|
||||
InnerException,
|
||||
Exception,
|
||||
Version,
|
||||
Entity
|
||||
)
|
||||
VALUES
|
||||
( @machineName,
|
||||
@application,
|
||||
@logged,
|
||||
@level,
|
||||
@message,
|
||||
@logger,
|
||||
@callsite,
|
||||
iif(@webrequestaction='',@webrequest, concat(@webrequest,' | action:',@webrequestaction)),
|
||||
@stacktrace,
|
||||
@innerException,
|
||||
@exception,
|
||||
@Version,
|
||||
@Entity
|
||||
);";
|
||||
|
||||
private static readonly Dictionary<string, string> DBLOG_Parameters = new Dictionary<string, string>() {
|
||||
//Globals
|
||||
{"@version", "${gdc:item=Version}"},
|
||||
{"@application", "${gdc:item=Application}"},
|
||||
|
||||
//Local
|
||||
//{"@webrequest", "${mdlc:item=Webrequest}"},
|
||||
{"@entity", "${mdlc:item=Entity}"},
|
||||
|
||||
//WebApi
|
||||
{"@webrequest", "${aspnet-request-url}"},
|
||||
{"@webrequestaction", "${aspnet-mvc-action}"},
|
||||
|
||||
//Nlog
|
||||
{"@machineName", "${machinename}" },
|
||||
{"@logged", "${date}"},
|
||||
{"@level", "${level:upperCase=true}"},
|
||||
{"@message", "${message}"},
|
||||
{"@logger", "${logger}"},
|
||||
{"@callSite", "${callsite:fileName=true:includeSourcePath=false:skipFrames=1}"}, //{"@callSite", "${callsite:filename=false:className=true:methodName=true}"},
|
||||
{"@stacktrace", "${stacktrace:topFrames=10}"},
|
||||
{"@InnerException", "${exception:format=Message,StackTrace,Data:maxInnerExceptionLevel=10}"},
|
||||
{"@Exception", "${exception:format=ToString}"},
|
||||
};
|
||||
|
||||
public static string AssemblyName { get; set; }
|
||||
public static string AssemblyVersion { get; set; }
|
||||
public static EN_LoggingLevel DBLogLevel { get; set; } = EN_LoggingLevel.Warn;
|
||||
public static EN_LoggingLevel FileLogLevel { get; set; } = EN_LoggingLevel.Error;
|
||||
public static string LogDirectory { get; set; } = String.Empty;
|
||||
public static string NlogConnectionstring { get; set; }
|
||||
public static LogLevel NlogDBLogLevel { get; set; }
|
||||
public static LogLevel NlogFileLogLevel { get; set; }
|
||||
public static NlogSentryConfig NlogSentryConfig { get; set; } = new NlogSentryConfig();
|
||||
|
||||
public static LoggingConfiguration CreateConfig()
|
||||
{
|
||||
NlogDBLogLevel = MapLogLevel(DBLogLevel);
|
||||
NlogFileLogLevel = MapLogLevel(FileLogLevel);
|
||||
|
||||
var config = new LoggingConfiguration();
|
||||
|
||||
DatabaseTarget dbTarget = CreateDatabaseTarget(config);
|
||||
var dbRule = new LoggingRule("*", NlogDBLogLevel, dbTarget);
|
||||
config.LoggingRules.Add(dbRule);
|
||||
|
||||
//Rules
|
||||
FileTarget targetFile = CreateFileTarget(config);
|
||||
var rule = new LoggingRule("*", NlogFileLogLevel, targetFile);
|
||||
config.LoggingRules.Add(rule);
|
||||
if (NlogSentryConfig.NlogSentryIsEnable)
|
||||
{
|
||||
AddSentry(config);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public static void Init(
|
||||
string assemblyName,
|
||||
string assemblyVersion,
|
||||
EN_LoggingLevel dbLogLevel = EN_LoggingLevel.Warn
|
||||
, EN_LoggingLevel fileLoogLevel = EN_LoggingLevel.Off
|
||||
, string logDirectory = "")
|
||||
{
|
||||
AssemblyVersion = assemblyVersion;
|
||||
AssemblyName = assemblyName;
|
||||
DBLogLevel = dbLogLevel;
|
||||
FileLogLevel = fileLoogLevel;
|
||||
LogDirectory = logDirectory;
|
||||
}
|
||||
|
||||
private static void AddSentry(LoggingConfiguration config)
|
||||
{
|
||||
config.AddSentry(o =>
|
||||
{
|
||||
o.Dsn = NlogSentryConfig.Dsn;
|
||||
|
||||
o.Layout = "${message}";
|
||||
|
||||
o.BreadcrumbLayout = "${logger}: ${message} #url: ${aspnet-request-url} | #action: ${aspnet-mvc-action}";
|
||||
// Optionally specify a separate format for breadcrumbs
|
||||
|
||||
o.MinimumBreadcrumbLevel = NlogSentryConfig.MinimumBreadcrumbLevel; // Debug and higher are stored as breadcrumbs (default is Info)
|
||||
o.MinimumEventLevel = NlogSentryConfig.MinimumEventLevel; // Error and higher is sent as event (default is Error)
|
||||
|
||||
// If DSN is not set, the SDK will look for an environment variable called SENTRY_DSN. If
|
||||
// nothing is found, SDK is disabled.
|
||||
|
||||
o.AttachStacktrace = NlogSentryConfig.AttachStacktrace;
|
||||
o.SendDefaultPii = NlogSentryConfig.SendDefaultPii; // Send Personal Identifiable information like the username of the user logged in to the device
|
||||
|
||||
o.IncludeEventDataOnBreadcrumbs = NlogSentryConfig.IncludeEventDataOnBreadcrumbs; // Optionally include event properties with breadcrumbs
|
||||
o.ShutdownTimeoutSeconds = 5;
|
||||
o.TracesSampleRate = 0.3;
|
||||
|
||||
//Optionally specify user properties via NLog (here using MappedDiagnosticsLogicalContext as an example)
|
||||
// o.User = new SentryNLogUser
|
||||
// {
|
||||
// Id = "${mdlc:item=id}",
|
||||
// Username = "${mdlc:item=username}",
|
||||
// Email = "${mdlc:item=email}",
|
||||
// IpAddress = "${mdlc:item=ipAddress}",
|
||||
// Other =
|
||||
//{
|
||||
// new TargetPropertyWithContext("mood", "joyous")
|
||||
//},
|
||||
//};
|
||||
|
||||
o.AddTag("Backend", "${gdc:item=Application}"); // Send the logger name as a tag
|
||||
o.AddTag("BackendVersion", "${gdc:item=Version}"); // Send the logger name as a tag
|
||||
o.AddTag("logger", "${logger}"); // Send the logger name as a tag
|
||||
|
||||
// Other configuration
|
||||
});
|
||||
}
|
||||
|
||||
private static DatabaseTarget CreateDatabaseTarget(LoggingConfiguration config)
|
||||
{
|
||||
var dbTarget = new DatabaseTarget
|
||||
{
|
||||
ConnectionString = NlogConnectionstring,
|
||||
|
||||
CommandText = DBLOG_CommandText
|
||||
};
|
||||
|
||||
foreach (var item in DBLOG_Parameters)
|
||||
{
|
||||
dbTarget.Parameters.Add(new DatabaseParameterInfo(item.Key, item.Value));
|
||||
}
|
||||
|
||||
config.AddTarget("database", dbTarget);
|
||||
return dbTarget;
|
||||
}
|
||||
|
||||
private static FileTarget CreateFileTarget(LoggingConfiguration config)
|
||||
{
|
||||
var targetFile =
|
||||
new FileTarget
|
||||
{
|
||||
FileName = Path.Combine(
|
||||
!string.IsNullOrEmpty(LogDirectory) ? LogDirectory : "${basedir}/_logs/",
|
||||
"${gdc:item=Application}" + "_V." + "${gdc:item=Version}" + $"_{DateTime.Now:yyyyMMdd}.log"),
|
||||
Layout = "${date}|${uppercase:${level}}|${stacktrace}|${message}" +
|
||||
"|${exception:format=Message,StackTrace,Data:maxInnerExceptionLevel=10}" +
|
||||
"${event-properties:item=EventId.Id}"
|
||||
};
|
||||
|
||||
config.AddTarget("logfile", targetFile);
|
||||
return targetFile;
|
||||
}
|
||||
|
||||
private static LogLevel MapLogLevel(EN_LoggingLevel loggingLevel)
|
||||
{
|
||||
LogLevel logLevel = LogLevel.Error;
|
||||
switch (loggingLevel)
|
||||
{
|
||||
case EN_LoggingLevel.Trace:
|
||||
logLevel = LogLevel.Trace;
|
||||
break;
|
||||
|
||||
case EN_LoggingLevel.Debug:
|
||||
logLevel = LogLevel.Debug;
|
||||
break;
|
||||
|
||||
case EN_LoggingLevel.Info:
|
||||
logLevel = LogLevel.Info;
|
||||
break;
|
||||
|
||||
case EN_LoggingLevel.Warn:
|
||||
logLevel = LogLevel.Warn;
|
||||
break;
|
||||
|
||||
case EN_LoggingLevel.Error:
|
||||
logLevel = LogLevel.Error;
|
||||
break;
|
||||
|
||||
case EN_LoggingLevel.Fatal:
|
||||
logLevel = LogLevel.Fatal;
|
||||
break;
|
||||
|
||||
case EN_LoggingLevel.Off:
|
||||
logLevel = LogLevel.Off;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return logLevel;
|
||||
}
|
||||
|
||||
public static void SetSentryUser(int id, string login, string email, IDictionary<string, string> others = null)
|
||||
{
|
||||
NlogSentryConfig.SentryUser = new Sentry.User { Id = id.ToString(), Username = login, Email = email };
|
||||
if (others != null) NlogSentryConfig.SentryUser.Other = others;
|
||||
Sentry.SentrySdk.ConfigureScope(scope => { scope.User = NlogSentryConfig.SentryUser; });
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace HRD.AppLogger
|
||||
{
|
||||
public interface ILoggerManager
|
||||
{
|
||||
void LogDebug(string message, string entityMessage = null, string webrequest = null, string userLogin = null);
|
||||
|
||||
void LogError(string message, string entityMessage = null, string webrequest = null, string userLogin = null);
|
||||
|
||||
void LogInfo(string message, string entityMessage = null, string webrequest = null, string userLogin = null);
|
||||
|
||||
void LogWarn(string message, string entityMessage = null, string webrequest = null, string userLogin = null);
|
||||
|
||||
void LogException(Exception exception, string entityMessage = null, string webrequest = null, string userLogin = null);
|
||||
}
|
||||
}
|
||||
@ -1,214 +0,0 @@
|
||||
using NLog;
|
||||
using Sentry;
|
||||
using System;
|
||||
|
||||
namespace HRD.AppLogger
|
||||
{
|
||||
public class LoggerManager : ILoggerManager
|
||||
{
|
||||
private static readonly ILogger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public LoggerManager(bool throwExceptions = true) : this()
|
||||
{
|
||||
LogManager.ThrowExceptions = throwExceptions;
|
||||
}
|
||||
|
||||
public LoggerManager()
|
||||
{
|
||||
GlobalDiagnosticsContext.Set("Version", AppLoggerConfig.AssemblyVersion);
|
||||
GlobalDiagnosticsContext.Set("Application", AppLoggerConfig.AssemblyName);
|
||||
|
||||
LogManager.ThrowConfigExceptions = true;
|
||||
LogManager.ThrowExceptions = false;
|
||||
LogManager.Configuration = AppLoggerConfig.CreateConfig();
|
||||
}
|
||||
|
||||
public void WriteLog(Action<Object> log, Object message, string entityMessage = null, string webrequest = null, string userLogin = null)
|
||||
{
|
||||
MappedDiagnosticsLogicalContext.Set("Entity", !String.IsNullOrEmpty(entityMessage) ? entityMessage : "");
|
||||
MappedDiagnosticsLogicalContext.Set("Webrequest", !String.IsNullOrEmpty(webrequest) ? webrequest : "");
|
||||
|
||||
if (AppLoggerConfig.NlogSentryConfig.NlogSentryIsEnable)
|
||||
{
|
||||
SentrySdk.WithScope(scope =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(entityMessage))
|
||||
{
|
||||
scope.SetTag("Entity", entityMessage);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(webrequest))
|
||||
{
|
||||
scope.SetTag("Webrequest", webrequest);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(userLogin))
|
||||
{
|
||||
scope.SetTag("UserLogin", userLogin);
|
||||
}
|
||||
|
||||
log(message);
|
||||
});
|
||||
}
|
||||
else log(message);
|
||||
}
|
||||
|
||||
public void LogDebug(string message, string entityMessage = null, string webrequest = null, string userLogin = null)
|
||||
{
|
||||
WriteLog(logger.Debug, message, entityMessage, webrequest, userLogin);
|
||||
|
||||
/* MappedDiagnosticsLogicalContext.Set("Entity", !String.IsNullOrEmpty(entityMessage) ? entityMessage : "");
|
||||
MappedDiagnosticsLogicalContext.Set("Webrequest", !String.IsNullOrEmpty(webrequest) ? webrequest : "");
|
||||
|
||||
if (AppLoggerConfig.NlogSentryConfig.NlogSentryIsEnable)
|
||||
{
|
||||
SentrySdk.WithScope(scope =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(entityMessage))
|
||||
{
|
||||
scope.SetTag("Entity", entityMessage);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(webrequest))
|
||||
{
|
||||
scope.SetTag("Webrequest", webrequest);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(userLogin))
|
||||
{
|
||||
scope.SetTag("UserLogin", userLogin);
|
||||
}
|
||||
|
||||
logger.Debug(message);
|
||||
});
|
||||
}
|
||||
else logger.Debug(message);*/
|
||||
}
|
||||
|
||||
public void LogError(string message, string entityMessage = null, string webrequest = null, string userLogin = null)
|
||||
{
|
||||
//WriteLog(logger.Error, message, entityMessage, webrequest, userLogin);
|
||||
MappedDiagnosticsLogicalContext.Set("Entity", !String.IsNullOrEmpty(entityMessage) ? entityMessage : "");
|
||||
MappedDiagnosticsLogicalContext.Set("Webrequest", !String.IsNullOrEmpty(webrequest) ? webrequest : "");
|
||||
|
||||
if (AppLoggerConfig.NlogSentryConfig.NlogSentryIsEnable)
|
||||
{
|
||||
SentrySdk.WithScope(scope =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(entityMessage))
|
||||
{
|
||||
scope.SetTag("Entity", entityMessage);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(webrequest))
|
||||
{
|
||||
scope.SetTag("Webrequest", webrequest);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(userLogin))
|
||||
{
|
||||
scope.SetTag("UserLogin", userLogin);
|
||||
}
|
||||
|
||||
logger.Error(message);
|
||||
});
|
||||
}
|
||||
else logger.Error(message);
|
||||
}
|
||||
|
||||
public void LogException(Exception exception, string entityMessage = null, string webrequest = null, string userLogin = null)
|
||||
{
|
||||
//WriteLog(logger.Error, exception, entityMessage, webrequest, userLogin);
|
||||
|
||||
MappedDiagnosticsLogicalContext.Set("Entity", !String.IsNullOrEmpty(entityMessage) ? entityMessage : "");
|
||||
MappedDiagnosticsLogicalContext.Set("Webrequest", !String.IsNullOrEmpty(webrequest) ? webrequest : "");
|
||||
|
||||
if (AppLoggerConfig.NlogSentryConfig.NlogSentryIsEnable)
|
||||
{
|
||||
SentrySdk.WithScope(scope =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(entityMessage))
|
||||
{
|
||||
scope.SetTag("Entity", entityMessage);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(webrequest))
|
||||
{
|
||||
scope.SetTag("Webrequest", webrequest);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(userLogin))
|
||||
{
|
||||
scope.SetTag("UserLogin", userLogin);
|
||||
}
|
||||
|
||||
logger.Error(exception);
|
||||
});
|
||||
}
|
||||
else logger.Error(exception);
|
||||
}
|
||||
|
||||
public void LogWarn(string message, string entityMessage = null, string webrequest = null, string userLogin = null)
|
||||
{
|
||||
//WriteLog(logger.Warn, message, entityMessage, webrequest, userLogin);
|
||||
|
||||
MappedDiagnosticsLogicalContext.Set("Entity", !String.IsNullOrEmpty(entityMessage) ? entityMessage : "");
|
||||
MappedDiagnosticsLogicalContext.Set("Webrequest", !String.IsNullOrEmpty(webrequest) ? webrequest : "");
|
||||
|
||||
if (AppLoggerConfig.NlogSentryConfig.NlogSentryIsEnable)
|
||||
{
|
||||
SentrySdk.WithScope(scope =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(entityMessage))
|
||||
{
|
||||
scope.SetTag("Entity", entityMessage);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(webrequest))
|
||||
{
|
||||
scope.SetTag("Webrequest", webrequest);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(userLogin))
|
||||
{
|
||||
scope.SetTag("UserLogin", userLogin);
|
||||
}
|
||||
|
||||
logger.Warn(message);
|
||||
});
|
||||
}
|
||||
else logger.Warn(message);
|
||||
}
|
||||
|
||||
public void LogInfo(string message, string entityMessage = null, string webrequest = null, string userLogin = null)
|
||||
{
|
||||
//WriteLog(logger.Info, message, entityMessage, webrequest, userLogin);
|
||||
MappedDiagnosticsLogicalContext.Set("Entity", !String.IsNullOrEmpty(entityMessage) ? entityMessage : "");
|
||||
MappedDiagnosticsLogicalContext.Set("Webrequest", !String.IsNullOrEmpty(webrequest) ? webrequest : "");
|
||||
|
||||
if (AppLoggerConfig.NlogSentryConfig.NlogSentryIsEnable)
|
||||
{
|
||||
SentrySdk.WithScope(scope =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(entityMessage))
|
||||
{
|
||||
scope.SetTag("Entity", entityMessage);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(webrequest))
|
||||
{
|
||||
scope.SetTag("Webrequest", webrequest);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(userLogin))
|
||||
{
|
||||
scope.SetTag("UserLogin", userLogin);
|
||||
}
|
||||
|
||||
logger.Info(message);
|
||||
});
|
||||
}
|
||||
else logger.Info(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
using NLog;
|
||||
using Sentry;
|
||||
|
||||
namespace HRD.AppLogger
|
||||
{
|
||||
public class NlogSentryConfig
|
||||
{
|
||||
public bool AttachStacktrace { get; set; } = false;
|
||||
public string Dsn { get; set; }
|
||||
|
||||
//
|
||||
// Summary:
|
||||
// Determines whether or not to include event-level data as data in breadcrumbs
|
||||
// for future errors. Defaults to false.
|
||||
public bool IncludeEventDataOnBreadcrumbs { get; set; } = false;
|
||||
|
||||
// Minimum log level to be included in the breadcrumb. Defaults to LogLevel.Info.
|
||||
public LogLevel MinimumBreadcrumbLevel { get; set; } = LogLevel.Warn;
|
||||
|
||||
//
|
||||
// Summary:
|
||||
// Minimum log level for events to trigger a send to Sentry. Defaults to LogLevel.Error.
|
||||
public LogLevel MinimumEventLevel { get; set; } = LogLevel.Warn;
|
||||
|
||||
public bool NlogSentryIsEnable { get; set; }
|
||||
public bool SendDefaultPii { get; set; } = false;
|
||||
public User? SentryUser { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
using HRD.AppLogger;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -10,7 +10,7 @@ namespace HRD.WebApi
|
||||
{
|
||||
public string WebRequestMethod { get; set; }
|
||||
public string WebRequestPath { get; set; }
|
||||
public EN_LoggingLevel LoggingLevel { get; set; } = EN_LoggingLevel.Info;
|
||||
public LogLevel LoggingLevel { get; set; } = LogLevel.Information;
|
||||
}
|
||||
|
||||
//TODO: remove this. configure each with iconfiguretion using ioptions interface
|
||||
@ -18,13 +18,14 @@ namespace HRD.WebApi
|
||||
{
|
||||
private static string _dalConnectionstring;
|
||||
|
||||
internal static EN_LoggingLevel GetMonitoringWebRequestLevel(string method, string path)
|
||||
internal static LogLevel GetMonitoringWebRequestLevel(string method, string path)
|
||||
{
|
||||
var entity = NlogMonitoringWebRequest.FirstOrDefault(
|
||||
x => x.WebRequestMethod.Equals(method, StringComparison.OrdinalIgnoreCase) &&
|
||||
(x.WebRequestPath == "*" || path.StartsWith(x.WebRequestPath, StringComparison.OrdinalIgnoreCase))
|
||||
);
|
||||
if (entity == default) { return EN_LoggingLevel.Off; }
|
||||
if (entity == default)
|
||||
return LogLevel.None;
|
||||
return entity.LoggingLevel;
|
||||
}
|
||||
|
||||
@ -69,15 +70,6 @@ namespace HRD.WebApi
|
||||
}
|
||||
}
|
||||
|
||||
AppLoggerConfig.Init(
|
||||
WebApiConfig.AssemblyName, WebApiConfig.AssemblyVersion,
|
||||
WebApiConfig.NlogDBLogLevel,
|
||||
WebApiConfig.NlogFileLogLevel,
|
||||
WebApiConfig.NlogLogDirectory);
|
||||
AppLoggerConfig.NlogConnectionstring = NlogConnectionstring;
|
||||
AppLoggerConfig.NlogSentryConfig.Dsn = WebApiConfig.NlogSentryDSN;
|
||||
AppLoggerConfig.NlogSentryConfig.NlogSentryIsEnable = WebApiConfig.NlogSentryIsEnable;
|
||||
|
||||
//custom
|
||||
var list = appSettings.GetSection("CustomConfig").GetChildren();
|
||||
foreach (var item in list)
|
||||
@ -86,14 +78,14 @@ namespace HRD.WebApi
|
||||
}
|
||||
}
|
||||
|
||||
public static EN_LoggingLevel ToEnumLoggingLevel(string enumString)
|
||||
public static LogLevel ToEnumLoggingLevel(string enumString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(enumString))
|
||||
{
|
||||
return EN_LoggingLevel.Off;
|
||||
return LogLevel.None;
|
||||
}
|
||||
|
||||
return (EN_LoggingLevel)Enum.Parse(typeof(EN_LoggingLevel), enumString);
|
||||
return (LogLevel)Enum.Parse(typeof(LogLevel), enumString);
|
||||
}
|
||||
|
||||
internal static void InitCustomSetting(Dictionary<string, string> customConfig)
|
||||
@ -136,8 +128,8 @@ namespace HRD.WebApi
|
||||
public static bool NlogSentryIsEnable { get; set; } = true;
|
||||
|
||||
public static string NlogConnectionstring { get; set; }
|
||||
public static EN_LoggingLevel NlogFileLogLevel { get; set; } = EN_LoggingLevel.Error;
|
||||
public static EN_LoggingLevel NlogDBLogLevel { get; set; } = EN_LoggingLevel.Error;
|
||||
public static LogLevel NlogFileLogLevel { get; set; } = LogLevel.Error;
|
||||
public static LogLevel NlogDBLogLevel { get; set; } = LogLevel.Error;
|
||||
|
||||
public static DbContextOptions<DbContext> SQLOptions()
|
||||
{
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using HRD.AppLogger;
|
||||
using HRD.WebApi.DAL;
|
||||
using HRD.WebApi.DAL;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
@ -15,12 +15,12 @@ namespace HRD.WebApi.Controllers
|
||||
public abstract class BaseController<TEntity> : Microsoft.AspNetCore.Mvc.Controller where TEntity : BaseEntity, new()
|
||||
{
|
||||
private readonly IBaseRepository<TEntity> _entityRepository;
|
||||
private readonly ILoggerManager _logger;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public BaseController(IBaseRepository<TEntity> baseRepository) : base()
|
||||
public BaseController(IBaseRepository<TEntity> baseRepository, ILogger logger) : base()
|
||||
{
|
||||
_entityRepository = baseRepository;
|
||||
_logger = new LoggerManager();
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
protected IBaseRepository<TEntity> EntityRepository => _entityRepository;
|
||||
@ -178,19 +178,19 @@ namespace HRD.WebApi.Controllers
|
||||
[NonAction]
|
||||
public void WriteLogException(Exception exception, String entityMessage = null)
|
||||
{
|
||||
_logger.LogException(exception, entityMessage);
|
||||
_logger.LogError(exception, "{message}", entityMessage);
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public void WriteLogInfo(string message)
|
||||
{
|
||||
_logger.LogInfo(message);
|
||||
_logger.LogError("{message}", message);
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public void WriteLogWarn(string message, String entityMessage = null)
|
||||
{
|
||||
_logger.LogWarn(message, entityMessage);
|
||||
_logger.LogError(message, "{message}", entityMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using HRD.AppLogger;
|
||||
using HRD.WebApi.DAL;
|
||||
using HRD.WebApi.DAL;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace HRD.WebApi.Controllers
|
||||
@ -10,43 +10,19 @@ namespace HRD.WebApi.Controllers
|
||||
[ApiController]
|
||||
public abstract class BaseMiniController : Microsoft.AspNetCore.Mvc.Controller
|
||||
{
|
||||
private readonly ILoggerManager _logger;
|
||||
protected readonly ILogger _logger;
|
||||
public readonly WebApiBaseContext Context;
|
||||
|
||||
public BaseMiniController(WebApiBaseContext webApiBaseContext)
|
||||
public BaseMiniController(WebApiBaseContext webApiBaseContext, ILogger logger)
|
||||
{
|
||||
Context = webApiBaseContext;
|
||||
_logger = new LoggerManager();
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public void WriteLogDebug(string message, String entityMessage = null)
|
||||
{
|
||||
WriteLogDebug(message, entityMessage);
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public void WriteLogError(string message, String entityMessage = null)
|
||||
{
|
||||
_logger.LogError(message, entityMessage);
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public void WriteLogException(Exception exception, String entityMessage = null)
|
||||
{
|
||||
_logger.LogException(exception, entityMessage);
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public void WriteLogInfo(string message)
|
||||
{
|
||||
_logger.LogInfo(message);
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public void WriteLogWarn(string message, String entityMessage = null)
|
||||
{
|
||||
_logger.LogWarn(message, entityMessage);
|
||||
_logger.LogError(exception, "{entityMessage}", entityMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
using HRD.WebApi.DAL;
|
||||
using HRD.WebApi.Helpers;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace HRD.WebApi.Controllers
|
||||
@ -10,7 +11,7 @@ namespace HRD.WebApi.Controllers
|
||||
[ApiController]
|
||||
public abstract class InfoBaseController : BaseMiniController
|
||||
{
|
||||
public InfoBaseController(WebApiBaseContext webApiBaseContext) : base(webApiBaseContext)
|
||||
public InfoBaseController(WebApiBaseContext webApiBaseContext, ILogger<InfoBaseController> logger) : base(webApiBaseContext, logger)
|
||||
{
|
||||
}
|
||||
|
||||
@ -24,7 +25,7 @@ namespace HRD.WebApi.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLogException(ex);
|
||||
_logger.LogError(ex, "{entityMessage}", ex.Message);
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
using HRD.AppLogger;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HRD.WebApi.Helpers
|
||||
{
|
||||
@ -27,10 +28,11 @@ namespace HRD.WebApi.Helpers
|
||||
Detail = errorFeature.Error.Message
|
||||
};
|
||||
|
||||
ILoggerManager logger = new LoggerManager();
|
||||
logger.LogException(errorFeature.Error, null, customError.URI);
|
||||
|
||||
await context.Response.WriteAsync(customError.ToJsonString()).ConfigureAwait(false);
|
||||
var loggerFactory = app.ApplicationServices.GetRequiredService<ILoggerFactory>();
|
||||
ILogger logger = loggerFactory.CreateLogger("ExceptionExtension");
|
||||
logger.LogError(errorFeature.Error, "An error occurred while processing the request. URI: {RequestUri}", customError.URI);
|
||||
|
||||
await context.Response.WriteAsync(JsonConvert.Serialize(customError)).ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using HRD.AppLogger;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
|
||||
@ -22,12 +21,7 @@ namespace HRD.WebApi.Helpers
|
||||
ConstructErrorMessages(context);
|
||||
}
|
||||
|
||||
public string URI { get; set; }
|
||||
|
||||
public string ToJsonString()
|
||||
{
|
||||
return JsonConvert.Serialize(this);
|
||||
}
|
||||
public string URI { get; init; }
|
||||
|
||||
private void ConstructErrorMessages(ActionContext context)
|
||||
{
|
||||
@ -37,12 +31,10 @@ namespace HRD.WebApi.Helpers
|
||||
var errors = keyModelStatePair.Value.Errors;
|
||||
if (errors != null && errors.Count > 0)
|
||||
{
|
||||
ILoggerManager logger = new LoggerManager();
|
||||
if (errors.Count == 1)
|
||||
{
|
||||
var errorMessage = GetErrorMessage(errors[0]);
|
||||
base.Errors.Add(key, new[] { errorMessage });
|
||||
logger.LogError(errorMessage, null, URI);
|
||||
Detail = errorMessage;
|
||||
}
|
||||
else
|
||||
@ -51,7 +43,6 @@ namespace HRD.WebApi.Helpers
|
||||
for (var i = 0; i < errors.Count; i++)
|
||||
{
|
||||
errorMessages[i] = GetErrorMessage(errors[i]);
|
||||
logger.LogError(errorMessages[i], null, URI);
|
||||
if (i == 0) { Detail = errorMessages[i]; }
|
||||
}
|
||||
base.Errors.Add(key, errorMessages);
|
||||
@ -60,10 +51,6 @@ namespace HRD.WebApi.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
private string GetErrorMessage(ModelError error)
|
||||
{
|
||||
return string.IsNullOrEmpty(error.ErrorMessage) ?
|
||||
"The input was not valid." : error.ErrorMessage;
|
||||
}
|
||||
private static string GetErrorMessage(ModelError error) => string.IsNullOrEmpty(error.ErrorMessage) ? "The input was not valid." : error.ErrorMessage;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -13,10 +14,12 @@ namespace HRD.WebApi.DAL.Middleware
|
||||
public class WebApiMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
private readonly ILogger<WebApiMiddleware> _logger;
|
||||
|
||||
public WebApiMiddleware(RequestDelegate next)
|
||||
public WebApiMiddleware(RequestDelegate next, ILogger<WebApiMiddleware> logger)
|
||||
{
|
||||
_next = next;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(HttpContext httpContext)
|
||||
@ -24,9 +27,9 @@ namespace HRD.WebApi.DAL.Middleware
|
||||
try
|
||||
{
|
||||
var loglevel = WebApiConfig.GetMonitoringWebRequestLevel(httpContext.Request.Method, httpContext.Request.Path.Value);
|
||||
if (loglevel == AppLogger.EN_LoggingLevel.Info
|
||||
|| loglevel == AppLogger.EN_LoggingLevel.Warn
|
||||
|| loglevel == AppLogger.EN_LoggingLevel.Error
|
||||
if (loglevel == LogLevel.Information
|
||||
|| loglevel == LogLevel.Warning
|
||||
|| loglevel == LogLevel.Error
|
||||
)
|
||||
{
|
||||
var requestReader = new StreamReader(httpContext.Request.Body);
|
||||
@ -35,10 +38,10 @@ namespace HRD.WebApi.DAL.Middleware
|
||||
{
|
||||
requestContent = $"{httpContext.Request.Method} {httpContext.Request.Path.Value}";
|
||||
}
|
||||
AppLogger.ILoggerManager logger = new AppLogger.LoggerManager();
|
||||
if (loglevel == AppLogger.EN_LoggingLevel.Info) { logger.LogInfo(requestContent); }
|
||||
if (loglevel == AppLogger.EN_LoggingLevel.Warn) { logger.LogWarn(requestContent); }
|
||||
if (loglevel == AppLogger.EN_LoggingLevel.Error) { logger.LogError(requestContent); }
|
||||
|
||||
if (loglevel == LogLevel.Information) { _logger.LogInformation(requestContent); }
|
||||
if (loglevel == LogLevel.Warning) { _logger.LogWarning(requestContent); }
|
||||
if (loglevel == LogLevel.Error) { _logger.LogError(requestContent); }
|
||||
}
|
||||
}
|
||||
catch (System.Exception)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using HRD.AppLogger;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace HRD.WebApi.DAL.Middleware
|
||||
@ -16,7 +16,7 @@ namespace HRD.WebApi.DAL.Middleware
|
||||
|
||||
public string NlogConnectionstring { get; set; } = String.Empty;
|
||||
|
||||
public EN_LoggingLevel NlogFileLogLevel { get; set; } = EN_LoggingLevel.Error;
|
||||
public EN_LoggingLevel NlogDBLogLevel { get; set; } = EN_LoggingLevel.Error;
|
||||
public LogLevel NlogFileLogLevel { get; set; } = LogLevel.Error;
|
||||
public LogLevel NlogDBLogLevel { get; set; } = LogLevel.Error;
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,11 @@
|
||||
using HRD.WebApi.DAL;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HRD.WebApi.Repositories
|
||||
{
|
||||
public abstract class BaseRepository<T> : BaseRepositoryCore<T> where T : BaseEntity
|
||||
{
|
||||
public BaseRepository(WebApiBaseContext repositoryContext) : base(repositoryContext)
|
||||
public BaseRepository(WebApiBaseContext repositoryContext, ILogger logger) : base(repositoryContext, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using HRD.AppLogger;
|
||||
using HRD.WebApi.DAL;
|
||||
using HRD.WebApi.DAL;
|
||||
using HRD.WebApi.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -12,19 +12,14 @@ namespace HRD.WebApi.Repositories
|
||||
{
|
||||
public abstract class BaseRepositoryCore<T> : IBaseRepository<T> where T : BaseEntityCore
|
||||
{
|
||||
private readonly ILoggerManager _logger;
|
||||
protected readonly ILogger _logger;
|
||||
|
||||
protected DbContext RepositoryContext { get; private set; }
|
||||
|
||||
protected BaseRepositoryCore(WebApiBaseContext repositoryContext)
|
||||
protected BaseRepositoryCore(WebApiBaseContext repositoryContext, ILogger logger)
|
||||
{
|
||||
RepositoryContext = repositoryContext;
|
||||
AppLoggerConfig.Init(
|
||||
WebApiConfig.AssemblyName,
|
||||
WebApiConfig.AssemblyVersion,
|
||||
WebApiConfig.NlogDBLogLevel,
|
||||
WebApiConfig.NlogFileLogLevel,
|
||||
WebApiConfig.NlogLogDirectory);
|
||||
_logger = new LoggerManager();
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public virtual bool Add(T entity, bool saveEntity = true)
|
||||
@ -592,28 +587,18 @@ namespace HRD.WebApi.Repositories
|
||||
_logger.LogDebug(message, entityMessage);
|
||||
}
|
||||
|
||||
public void WriteLogError(string message, String entityMessage = null)
|
||||
public void WriteLogError(string message, string entityMessage = null)
|
||||
{
|
||||
_logger.LogError(message, entityMessage);
|
||||
_logger.LogError(message, "{entityMessage}", entityMessage);
|
||||
}
|
||||
|
||||
public void WriteLogException(Exception exception, String entityMessage = null)
|
||||
public void WriteLogException(Exception exception, string entityMessage = null)
|
||||
{
|
||||
_logger.LogException(exception, entityMessage);
|
||||
_logger.LogError(exception, "{entityMessage}", entityMessage);
|
||||
if (WebApiConfig.RaiseRepositoryExceptions)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteLogInfo(string message)
|
||||
{
|
||||
_logger.LogInfo(message);
|
||||
}
|
||||
|
||||
public void WriteLogWarn(string message, String entityMessage = null)
|
||||
{
|
||||
_logger.LogWarn(message, entityMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,13 +2,14 @@ using DAL.Models.Entities;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.Controllers
|
||||
{
|
||||
[JWTAuthorize]
|
||||
public class AdWebAppToWebAppRoleController : BaseController<AdWebAppToWebAppRole>
|
||||
{
|
||||
public AdWebAppToWebAppRoleController(IBaseRepository<AdWebAppToWebAppRole> repositoryBase) : base(repositoryBase)
|
||||
public AdWebAppToWebAppRoleController(IBaseRepository<AdWebAppToWebAppRole> repositoryBase, ILogger<AdWebAppToWebAppRoleController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,14 @@ using DAL.Models.Entities;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.Controllers
|
||||
{
|
||||
[JWTAuthorize]
|
||||
public class CostCentreController : BaseController<CostCentre>
|
||||
{
|
||||
public CostCentreController(IBaseRepository<CostCentre> repositoryBase) : base(repositoryBase)
|
||||
public CostCentreController(IBaseRepository<CostCentre> repositoryBase, ILogger<CostCentreController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
@ -15,7 +16,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class DepartmentController : BaseController<Department>
|
||||
{
|
||||
public DepartmentController(IBaseRepository<Department> repositoryBase) : base(repositoryBase)
|
||||
public DepartmentController(IBaseRepository<Department> repositoryBase, ILogger<DepartmentController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class DepartmentToWebAppToEmployeeForWindreamController : BaseController<DepartmentToWebAppToEmployeeForWindream>
|
||||
{
|
||||
public DepartmentToWebAppToEmployeeForWindreamController(IBaseRepository<DepartmentToWebAppToEmployeeForWindream> repositoryBase) : base(repositoryBase)
|
||||
public DepartmentToWebAppToEmployeeForWindreamController(IBaseRepository<DepartmentToWebAppToEmployeeForWindream> repositoryBase, ILogger<DepartmentToWebAppToEmployeeForWindreamController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,13 +2,14 @@ using DAL.Models.Entities;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.Controllers
|
||||
{
|
||||
[JWTAuthorize]
|
||||
public class DocumentArtController : BaseController<DocumentArt>
|
||||
{
|
||||
public DocumentArtController(IBaseRepository<DocumentArt> repositoryBase) : base(repositoryBase)
|
||||
public DocumentArtController(IBaseRepository<DocumentArt> repositoryBase, ILogger<DocumentArtController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class DocumentArtToDepartmentController : BaseController<DocumentArtToDepartment>
|
||||
{
|
||||
public DocumentArtToDepartmentController(IBaseRepository<DocumentArtToDepartment> repositoryBase) : base(repositoryBase)
|
||||
public DocumentArtToDepartmentController(IBaseRepository<DocumentArtToDepartment> repositoryBase, ILogger<DocumentArtToDepartmentController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,13 +2,14 @@ using DAL.Models.Entities;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.Controllers
|
||||
{
|
||||
[JWTAuthorize]
|
||||
public class EmployeeAttributeController : BaseController<EmployeeAttribute>
|
||||
{
|
||||
public EmployeeAttributeController(IBaseRepository<EmployeeAttribute> repositoryBase) : base(repositoryBase)
|
||||
public EmployeeAttributeController(IBaseRepository<EmployeeAttribute> repositoryBase, ILogger<EmployeeAttributeController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -13,7 +14,7 @@ namespace StaffDBServer.Controllers
|
||||
{
|
||||
public class EmployeeController : BaseController<Employee>
|
||||
{
|
||||
public EmployeeController(IBaseRepository<Employee> repositoryBase) : base(repositoryBase)
|
||||
public EmployeeController(IBaseRepository<Employee> repositoryBase, ILogger<EmployeeController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,13 +2,14 @@ using DAL.Models.Entities;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.Controllers
|
||||
{
|
||||
[JWTAuthorize]
|
||||
public class EmployeeStatusController : BaseController<EmployeeStatus>
|
||||
{
|
||||
public EmployeeStatusController(IBaseRepository<EmployeeStatus> repositoryBase) : base(repositoryBase)
|
||||
public EmployeeStatusController(IBaseRepository<EmployeeStatus> repositoryBase, ILogger<EmployeeStatusController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class EmployeeToAttributeController : BaseController<EmployeeToAttribute>
|
||||
{
|
||||
public EmployeeToAttributeController(IBaseRepository<EmployeeToAttribute> repositoryBase) : base(repositoryBase)
|
||||
public EmployeeToAttributeController(IBaseRepository<EmployeeToAttribute> repositoryBase, ILogger<EmployeeToAttributeController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class EmployeeToDepartmentController : BaseController<EmployeeToDepartment>
|
||||
{
|
||||
public EmployeeToDepartmentController(IBaseRepository<EmployeeToDepartment> repositoryBase) : base(repositoryBase)
|
||||
public EmployeeToDepartmentController(IBaseRepository<EmployeeToDepartment> repositoryBase, ILogger<EmployeeToDepartmentController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class EmployeeToWebAppController : BaseController<EmployeeToWebApp>
|
||||
{
|
||||
public EmployeeToWebAppController(IBaseRepository<EmployeeToWebApp> repositoryBase) : base(repositoryBase)
|
||||
public EmployeeToWebAppController(IBaseRepository<EmployeeToWebApp> repositoryBase, ILogger<EmployeeToWebAppController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,13 +2,14 @@ using DAL.Models.Entities;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.Controllers
|
||||
{
|
||||
[JWTAuthorize]
|
||||
public class ProjectController : BaseController<Project>
|
||||
{
|
||||
public ProjectController(IBaseRepository<Project> repositoryBase) : base(repositoryBase)
|
||||
public ProjectController(IBaseRepository<Project> repositoryBase, ILogger<ProjectController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,14 @@ using DAL.Models.Entities;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.Controllers
|
||||
{
|
||||
[JWTAuthorize]
|
||||
public class RangController : BaseController<Rang>
|
||||
{
|
||||
public RangController(IBaseRepository<Rang> repositoryBase) : base(repositoryBase)
|
||||
public RangController(IBaseRepository<Rang> repositoryBase, ILogger<RangController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,14 @@ using DAL.Models.Entities;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.Controllers
|
||||
{
|
||||
[JWTAuthorize]
|
||||
public class SubsidiaryController : BaseController<Subsidiary>
|
||||
{
|
||||
public SubsidiaryController(IBaseRepository<Subsidiary> repositoryBase) : base(repositoryBase)
|
||||
public SubsidiaryController(IBaseRepository<Subsidiary> repositoryBase, ILogger<SubsidiaryController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WebAppAdditionalRoleController : BaseController<WebAppAdditionalRole>
|
||||
{
|
||||
public WebAppAdditionalRoleController(IBaseRepository<WebAppAdditionalRole> repositoryBase) : base(repositoryBase)
|
||||
public WebAppAdditionalRoleController(IBaseRepository<WebAppAdditionalRole> repositoryBase, ILogger<WebAppAdditionalRoleController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2,13 +2,14 @@ using DAL.Models.Entities;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.Controllers
|
||||
{
|
||||
[JWTAuthorize]
|
||||
public class WebAppController : BaseController<WebApp>
|
||||
{
|
||||
public WebAppController(IBaseRepository<WebApp> repositoryBase) : base(repositoryBase)
|
||||
public WebAppController(IBaseRepository<WebApp> repositoryBase, ILogger<WebAppController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,14 @@ using DAL.Models.Entities;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.Controllers
|
||||
{
|
||||
[JWTAuthorize]
|
||||
public class WebAppRoleController : BaseController<WebAppRole>
|
||||
{
|
||||
public WebAppRoleController(IBaseRepository<WebAppRole> repositoryBase) : base(repositoryBase)
|
||||
public WebAppRoleController(IBaseRepository<WebAppRole> repositoryBase, ILogger<WebAppRoleController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WebAppToDepartmentController : BaseController<WebAppToDepartment>
|
||||
{
|
||||
public WebAppToDepartmentController(IBaseRepository<WebAppToDepartment> repositoryBase) : base(repositoryBase)
|
||||
public WebAppToDepartmentController(IBaseRepository<WebAppToDepartment> repositoryBase, ILogger<WebAppToDepartmentController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WebAppToWebAppAdditionalRoleController : BaseController<WebAppToWebAppAdditionalRole>
|
||||
{
|
||||
public WebAppToWebAppAdditionalRoleController(IBaseRepository<WebAppToWebAppAdditionalRole> repositoryBase) : base(repositoryBase)
|
||||
public WebAppToWebAppAdditionalRoleController(IBaseRepository<WebAppToWebAppAdditionalRole> repositoryBase, ILogger<WebAppToWebAppAdditionalRoleController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WebAppToWebAppRoleController : BaseController<WebAppToWebAppRole>
|
||||
{
|
||||
public WebAppToWebAppRoleController(IBaseRepository<WebAppToWebAppRole> repositoryBase) : base(repositoryBase)
|
||||
public WebAppToWebAppRoleController(IBaseRepository<WebAppToWebAppRole> repositoryBase, ILogger<WebAppToWebAppRoleController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WindreamColumnsToDepartmentController : BaseController<WindreamColumnsToDepartment>
|
||||
{
|
||||
public WindreamColumnsToDepartmentController(IBaseRepository<WindreamColumnsToDepartment> repositoryBase) : base(repositoryBase)
|
||||
public WindreamColumnsToDepartmentController(IBaseRepository<WindreamColumnsToDepartment> repositoryBase, ILogger<WindreamColumnsToDepartmentController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WindreamIndexController : BaseController<WindreamIndex>
|
||||
{
|
||||
public WindreamIndexController(IBaseRepository<WindreamIndex> repositoryBase) : base(repositoryBase)
|
||||
public WindreamIndexController(IBaseRepository<WindreamIndex> repositoryBase, ILogger<WindreamIndexController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WindreamIndexToWindreamSearchToDepartmentController : BaseController<WindreamIndexToWindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamIndexToWindreamSearchToDepartmentController(IBaseRepository<WindreamIndexToWindreamSearchToDepartment> repositoryBase) : base(repositoryBase)
|
||||
public WindreamIndexToWindreamSearchToDepartmentController(IBaseRepository<WindreamIndexToWindreamSearchToDepartment> repositoryBase, ILogger<WindreamIndexToWindreamSearchToDepartmentController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WindreamInputFolderController : BaseController<WindreamInputFolder>
|
||||
{
|
||||
public WindreamInputFolderController(IBaseRepository<WindreamInputFolder> repositoryBase) : base(repositoryBase)
|
||||
public WindreamInputFolderController(IBaseRepository<WindreamInputFolder> repositoryBase, ILogger<WindreamInputFolderController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WindreamSearchController : BaseController<WindreamSearch>
|
||||
{
|
||||
public WindreamSearchController(IBaseRepository<WindreamSearch> repositoryBase) : base(repositoryBase)
|
||||
public WindreamSearchController(IBaseRepository<WindreamSearch> repositoryBase, ILogger<WindreamSearchController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WindreamSearchItemController : BaseController<WindreamSearchItem>
|
||||
{
|
||||
public WindreamSearchItemController(IBaseRepository<WindreamSearchItem> repositoryBase) : base(repositoryBase)
|
||||
public WindreamSearchItemController(IBaseRepository<WindreamSearchItem> repositoryBase, ILogger<WindreamSearchItemController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WindreamSearchItemToWindreamSearchToDepartmentController : BaseController<WindreamSearchItemToWindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamSearchItemToWindreamSearchToDepartmentController(IBaseRepository<WindreamSearchItemToWindreamSearchToDepartment> repositoryBase) : base(repositoryBase)
|
||||
public WindreamSearchItemToWindreamSearchToDepartmentController(IBaseRepository<WindreamSearchItemToWindreamSearchToDepartment> repositoryBase, ILogger<WindreamSearchItemToWindreamSearchToDepartmentController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using HRD.WebApi.Controllers;
|
||||
using HRD.WebApi.Repositories;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
@ -15,7 +16,7 @@ namespace StaffDBServer.Controllers
|
||||
[JWTAuthorize]
|
||||
public class WindreamSearchToDepartmentController : BaseController<WindreamSearchToDepartment>
|
||||
{
|
||||
public WindreamSearchToDepartmentController(IBaseRepository<WindreamSearchToDepartment> repositoryBase) : base(repositoryBase)
|
||||
public WindreamSearchToDepartmentController(IBaseRepository<WindreamSearchToDepartment> repositoryBase, ILogger<WindreamSearchToDepartmentController> logger) : base(repositoryBase, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using DAL;
|
||||
using HRD.AppLogger;
|
||||
using HRD.WebApi;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
@ -23,17 +22,10 @@ using NSwag;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NLog;
|
||||
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) =>
|
||||
{
|
||||
ILoggerManager logger = new LoggerManager();
|
||||
logger.LogException((Exception)unhandledExceptionEventArgs.ExceptionObject, "Application closed due to exception.");
|
||||
NLog.LogManager.Flush();
|
||||
};
|
||||
|
||||
ILoggerManager logger = new LoggerManager();
|
||||
logger.LogWarn($"[Start WebApi Server] BaseDirectory: {AppDomain.CurrentDomain.BaseDirectory}; TargetFrameworkName: {AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}");
|
||||
|
||||
var logger = NLog.LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||
try
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@ -62,9 +54,7 @@ try
|
||||
builder.Services.ConfigureJWT(StaffDBServer.Extends.JwtMiddlewareOptionsHelper.GetJwtMiddlewareOptions()); ;
|
||||
|
||||
builder.Services.ConfigureDAL(WebApiMiddlewareOptionsHelper.GetWebApiMiddlewareOptions());
|
||||
|
||||
builder.Services.AddSingleton<ILoggerManager, LoggerManager>();
|
||||
|
||||
|
||||
//SWAGGER
|
||||
builder.Services.AddSwaggerDocument(config =>
|
||||
{
|
||||
@ -165,7 +155,7 @@ try
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogException(ex, "Stopped program because of exception");
|
||||
logger.Log(NLog.LogLevel.Error, ex, $"Stopped program because of exception\n{ex.Message}");
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using DAL;
|
||||
using HRD.WebApi.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StaffDBServer.SharedExtensions
|
||||
{
|
||||
@ -9,7 +10,7 @@ namespace StaffDBServer.SharedExtensions
|
||||
[ApiController]
|
||||
public class InfoController : InfoBaseController
|
||||
{
|
||||
public InfoController(WebApiContext context) : base(context)
|
||||
public InfoController(WebApiContext context, ILogger<InfoController> logger) : base(context, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi.Controllers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
@ -17,7 +18,7 @@ namespace StaffDBServer.SharedControllers
|
||||
private readonly WebAppUserRepository webAppUserRepository;
|
||||
private readonly WebAppUserHelper webAppUserHelper;
|
||||
|
||||
public WebAppUserController(WebApiContext context, WebAppUserRepository webAppUserRepository, WebAppUserHelper webAppUserHelper) : base(context)
|
||||
public WebAppUserController(WebApiContext context, WebAppUserRepository webAppUserRepository, WebAppUserHelper webAppUserHelper, ILogger<WebAppUserController> logger) : base(context, logger)
|
||||
{
|
||||
this.webAppUserRepository = webAppUserRepository;
|
||||
this.webAppUserHelper = webAppUserHelper;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
"Default": "Information"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
@ -14,15 +14,57 @@
|
||||
"OfficeFileServerUrl": ""
|
||||
},
|
||||
|
||||
"Nlog": {
|
||||
"NlogConnectionstring": "%sqlConnection%",
|
||||
"NlogDBLogLevel": "Warn",
|
||||
"NlogFileLogLevel": "Warn",
|
||||
"NlogLogDirectory": "c:\\temp\\_logs\\",
|
||||
"NlogSentryDSN": "",
|
||||
"NlogSentryIsEnable": "false"
|
||||
// "Nlog": {
|
||||
// "NlogConnectionstring": "%sqlConnection%",
|
||||
// "NlogDBLogLevel": "Warn",
|
||||
// "NlogFileLogLevel": "Warn",
|
||||
// "NlogLogDirectory": "c:\\temp\\_logs\\",
|
||||
// "NlogSentryDSN": "",
|
||||
// "NlogSentryIsEnable": "false"
|
||||
// },
|
||||
"NLog": {
|
||||
"LogLevel": {
|
||||
"Default": "Info"
|
||||
},
|
||||
"Targets": {
|
||||
"console": {
|
||||
"type": "Console",
|
||||
"layout": "${longdate}|${level:uppercase=true}|${message}${onexception:${newline}${exception:format=ToString}}"
|
||||
},
|
||||
"infoFile": {
|
||||
"type": "File",
|
||||
"fileName": "E:\\LogFiles\\DigitalData\\info.log",
|
||||
"layout": "${longdate}|${level:uppercase=true}|${message}${onexception:${newline}${exception:format=ToString}}"
|
||||
},
|
||||
"warnFile": {
|
||||
"type": "File",
|
||||
"fileName": "E:\\LogFiles\\DigitalData\\warn.log",
|
||||
"layout": "${longdate}|${level:uppercase=true}|${message}${onexception:${newline}${exception:format=ToString}}"
|
||||
},
|
||||
"errorFile": {
|
||||
"type": "File",
|
||||
"fileName": "E:\\LogFiles\\DigitalData\\error.log",
|
||||
"layout": "${longdate}|${level:uppercase=true}|${message}${onexception:${newline}${exception:format=ToString}}"
|
||||
}
|
||||
},
|
||||
"Rules": [
|
||||
{
|
||||
"logger": "*",
|
||||
"minLevel": "Info",
|
||||
"writeTo": "console,infoFile"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"minLevel": "Warn",
|
||||
"writeTo": "console,warnFile"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"minLevel": "Error",
|
||||
"writeTo": "console,errorFile"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"CustomConfig": {
|
||||
},
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using HRD.AppLogger;
|
||||
using HRD.LDAPService;
|
||||
using HRD.LDAPService;
|
||||
using HRD.LDAPService.JWT;
|
||||
using HRD.WebApi;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
@ -23,8 +22,6 @@ namespace XUnitWebApi.SharedConfig
|
||||
WebApiConfig.AssemblyVersion = "xxx.xx";
|
||||
//WebApiConfig.Connectionstring = Config_ConnectionString;
|
||||
//WebApiConfig.NlogConnectionstring = Config_ConnectionString;
|
||||
WebApiConfig.NlogDBLogLevel = EN_LoggingLevel.Error;
|
||||
WebApiConfig.NlogFileLogLevel = EN_LoggingLevel.Off;
|
||||
WebApiConfig.RaiseRepositoryExceptions = false;
|
||||
|
||||
//JWT#1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user