我正在使用Elmah在使用SqlLite数据库的ASP.NET MVC中记录未处理的异常。当我使用
使用SqlLite数据库配置Elmah时<elmah>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on remote access and securing ELMAH.
-->
<security allowRemoteAccess="false" />
<errorLog type="Elmah.SQLiteErrorLog, Elmah" connectionStringName="Elmah" />
</elmah>
使用下面的连接字符串
<connectionStrings>
<add name="Elmah" connectionString="data source=~/App_Data/Error.db" />
</connectionStrings>
它抛出此异常
SQLiteException (0x1): SQL logic error
no such table: Error]
System.Data.SQLite.SQLite3.Prepare(SQLiteConnection cnn, String strSql, SQLiteStatement previous, UInt32 timeoutMS, String& strRemain) +1239
System.Data.SQLite.SQLiteCommand.BuildNextCommand() +374
System.Data.SQLite.SQLiteCommand.GetStatement(Int32 index) +18
System.Data.SQLite.SQLiteDataReader.NextResult() +309
System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave) +266
System.Data.`enter code here`SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior) +45
System.Data.SQLite.SQLiteCommand.ExecuteReader() +21
Elmah.SQLiteErrorLog.GetErrors(Int32 pageIndex, Int32 pageSize, IList errorEntryList) +235
Elmah.ErrorLogPage.OnLoad(EventArgs e) +336
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678`
有人可以告诉我我错了吗
我如何用Elmah配置SqlLite数据库进行记录?
答案 0 :(得分:0)
由于SQLLiteErrorLog
does this automatically,因此您无需手动创建数据库或运行脚本。我刚刚对此进行了测试,并且可以这样做:
web.config
<connectionStrings>
<add name="Elmah" connectionString="data source=~/App_Data/Error.db" />
</connectionStrings>
...
<elmah>
<security allowRemoteAccess="false" />
<errorLog type="Elmah.SQLiteErrorLog, Elmah" connectionStringName="Elmah" />
</elmah>
/elmah.axd
。我执行了上述步骤,并在我的一个控制器中强制执行了异常并请求了该路由。 Error.db
文件已成功创建,并记录了错误。
如果Error.db
文件夹中已经有一个名为App_Data
的文件,请尝试将其删除并重试。