I am using NLog.web and Nlog.config . Able to log error to file . When try to log to database. Getting target database cant be found.
Please help if any one using Nlog with asp.net core rc1 and logging error to database
My configuration look likes
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogFile="Nlog.log">
<targets>
<target name="file" xsi:type="File" layout="${longdate}|${level}|${callsite}|${logger}|${threadid}|${windows-identity:domain=false}--${message} ${exception:format=message,stacktrace:separator=*" fileName="c:\psnet\myapplication.log"/>
<target name="database" type="Database">
<connectionString>
Data Source=databaseservername;Initial Catalog=databasename;User Id=username;Password=password;
</connectionString>
<commandText>
insert into system_logging(log_date,log_level,log_logger,log_message,log_machine_name, log_user_name, log_call_site, log_thread, log_exception, log_stacktrace) values(@time_stamp, @level, @logger, @message,@machinename, @user_name, @call_site, @threadid, @log_exception, @stacktrace);
</commandText>
<parameter name="@time_stamp" layout="${longdate}"/>
<parameter name="@level" layout="${level}"/>
<parameter name="@logger" layout="${logger}"/>
<parameter name="@message" layout="${message}"/>
<parameter name="@machinename" layout="${machinename}"/>
<parameter name="@user_name" layout="${windows-identity:domain=true}"/>
<parameter name="@call_site" layout="${callsite:filename=true}"/>
<parameter name="@threadid" layout="${threadid}"/>
<parameter name="@log_exception" layout="${exception}"/>
<parameter name="@stacktrace" layout="${stacktrace}"/>
</target>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="file"/>
<logger name="*" minlevel="Info" appendTo="database"/>
</rules>
</nlog>
I am able to write to file.. IN Nog internal file it showing error target database is unkown Even when trying to write to event log showing same error Target EventLog is unknown
Please help me to fix this issue