not able to save log to sqlite

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

not able to save log to sqlite

Abhijit Dass
hi,
i want to logging exception details to sqlite database using Nlog
libraries, m okay when i store logging details by using ado.net code but m
not able to insert log details when i use nlog.config. please help me out
how can i insert logging details by nlog.config.

here is my code-----------------

<?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"
     throwExceptions="false">
   <targets>
     <target name="file" xsi:type="File"
          layout="
            ---------------------------------------------------${newline}
              ${longdate} ${newline}

---------------------------------------------------------${newline}

              Level: ${level}${newline}

              User Id: ${aspnet-User-Identity}
              Action: ${aspnet-MVC-Action}${newline}
              Controller: ${aspnet-MVC-Controller}${newline}
              Ip: ${aspnet-Request-IP}${newline}

              Call Site:  ${callsite} ${newline}


              ${logger}${newline}
              ${message}${newline}
              ${exception:format=message}${newline}

${exception:format=:innerFormat=ShortType,Message,Method:MaxInnerExceptionLevel=1:InnerExceptionSeparator=}${newline}
              "
          fileName="D:/ErrorLog/example.log"
          keepFileOpen="false"
          encoding="iso-8859-2" />

     <target name="db" xsi:type="Database"
         dbProvider="System.Data.SQLite" keepConnection="false"
         connectionString="Data
Source=$C:\Users\abhijitd\Desktop\Test\Log.db3;Version=3;"
         commandText="INSERT into Log(Time, SeverityLevel, ClassName,
LogText)
          values(@Time, @SeverityLevel, @ClassName, @LogText)">
           <parameter name="@Time" layout="${longdate}"/>
           <parameter name="@SeverityLevel"
layout="${level:uppercase=true}"/>
           <parameter name="@ClassName"
layout="${aspnet-MVC-Controller}"/>
           <parameter name="@LogText" layout="${message}"/>
     </target>
   </targets>
   <rules>
     <logger name="*" minlevel="Warn" writeTo="db" />
    <logger name="*" minlevel="Warn" writeTo="file" />
 </rules>
 </nlog>



Thanks and regards
Abhijit Dass
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: not able to save log to sqlite

Joe Mistachkin-3

Abhijit Dass wrote:
>
> i want to logging exception details to sqlite database using
> Nlog libraries, m okay when i store logging details by using
> ado.net code but m not able to insert log details when i use
> nlog.config. please help me out how can i insert logging
> details by nlog.config.
>

I have not used this component; however, is there some reason
why the file name in the connection string is prefixed with a
dollar sign?

>
>          connectionString="Data
> Source=$C:\Users\abhijitd\Desktop\Test\Log.db3;Version=3;"
>

Also, the connection string must use "Data Source", with a
space between the words.  I'm not sure if the space is be
preserved in your config file.

--
Joe Mistachkin

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users