I created an nlog configuration with the following code
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true" internalLogFile="c:\nlog.txt" internalLogLevel="Debug">
<targets>
<target name="Console" xsi:type="Console" layout="${level:uppercase=true} ${message}" />
<target name="DelivrosLogFile" xsi:type="File" fileName="C:\DelivrosLogs\Delivros.log" layout="${longdate} |${message}| ${stacktrace}" />
<target xsi:type="Database" name="DelivrosDatabaseLogging" connectionStringName="DelivrosNlog" commandText="INSERT INTO tbl_ErrorLogIn( Event_ID,Priority,Severity,Title,Timestamp,MachineName,AppDomainName,PocessID,ProcessName,ThreadName,Win32ThreadId,Message,FormattedMessage) VALUES (@Event_ID,@Priority,@Severity,@Title,@Timestamp,@MachineName,@AppDomainName,@PocessID,@ProcessName,@ThreadName,@Win32ThreadId,@Message,@FormattedMessage)">
<parameter name="@Event_ID" layout="0" />
<parameter name="@Priority" layout="3" />
<parameter name="@Severity" layout="${level}" />
<parameter name="@Title" layout="Journal API" />
<parameter name="@Timestamp" layout="${date}" />
<parameter name="@MachineName" layout="${machinename}" />
<parameter name="@AppDomainName" layout="Journal API" />
<parameter name="@PocessID" layout="${processid}" />
<parameter name="@ProcessName" layout="${processname}" />
<parameter name="@ThreadName" layout="${threadname}" />
<parameter name="@Win32ThreadId" layout="${threadid}" />
<parameter name="@Message" layout="${exception}" />
<parameter name="@FormattedMessage" layout="${message} " />
</target>
</targets>
<rules>
<logger name="*" levels="Info,Warn,Error,Fatal" writeTo="Console" />
<logger name="*" levels="Info,Warn,Fatal" writeTo="DelivrosLogFile" />
<logger name="*" levels="Error" writeTo="DelivrosDatabaseLogging" />
</rules>
and I created three class files in my other layer named D.Exception.Abstract and passed it to my controller.
and when I tried to run the application with the following code
public ActionResult UserRegistration()
{
logger.Info("We're on the Index page for Activities");
try
{
throw new System.Exception("A test exception");
}
catch (System.Exception ex)
{
logger.Error("An error has occurred", ex);
}
return View("UserRegistration");
}
error: "The format of the initialization string does not comply with the specification starting with index 158".
Please help me ... there aren’t a lot of forums for NLog, and I am starting and applying this for the first time ...