Skip to content

Commit

Permalink
Merge pull request #124 from SkillsFundingAgency/NlogFix
Browse files Browse the repository at this point in the history
Nlog fix
  • Loading branch information
Najamuddin-Muhammad authored Jun 16, 2020
2 parents a79898b + 9241396 commit 0e97ac6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/SFA.DAS.EmployerCommitmentsV2.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
using NLog.Web;
using SFA.DAS.EmployerCommitmentsV2.Web.Startup;
using StructureMap.AspNetCore;
using System;

namespace SFA.DAS.EmployerCommitmentsV2.Web
{
public static class Program
{
public static void Main(string[] args)
{
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var logger = NLogBuilder.ConfigureNLog(environment == "Development" ? "nlog.Development.config" : "nlog.config").GetCurrentClassLogger();
logger.Info("Starting up host");

CreateWebHostBuilder(args).Build().Run();
}

Expand Down
19 changes: 19 additions & 0 deletions src/SFA.DAS.EmployerCommitmentsV2.Web/nlog.Development.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="info"
internalLogFile="internal-nlog.txt"
throwExceptions="false">

<variable name="appName" value="das-employercommitments-v2-web" />
<variable name="simplelayout" value="${longdate} [${uppercase:${level}}] [${logger}] - ${message} ${onexception:${exception:format=tostring}}" />
<targets>
<target name="Console" layout="${simplelayout}" xsi:type="Console" />
<target name="File" fileName="${basedir}/logs/${appName}.${shortdate}.log" layout="${simplelayout}" xsi:type="File" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="File" />
</rules>
</nlog>
3 changes: 1 addition & 2 deletions src/SFA.DAS.EmployerCommitmentsV2.Web/nlog.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
<variable name="simplelayout" value="${longdate} [${uppercase:${level}}] [${logger}] - ${message} ${onexception:${exception:format=tostring}}" />
<targets>
<target name="Console" layout="${simplelayout}" xsi:type="Console" />
<target name="File" fileName="${basedir}/logs/${appName}.${shortdate}.log" layout="${simplelayout}" xsi:type="File" />
<target name="Redis" appName="${appName}" environmentKeyName="APPSETTING_EnvironmentName" connectionStringName="APPSETTING_LoggingRedisConnectionString" includeAllProperties="true" layout="${message}" xsi:type="Redis" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="File, Redis" />
<logger name="*" minlevel="Info" writeTo="Redis" />
</rules>
</nlog>

0 comments on commit 0e97ac6

Please sign in to comment.