I'm trying to implement a log4net with a sqlite db file, but when I log something nothing happens.
My configuration:
<log4net>
<appender name="sqlite-appender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SQLite.SQLiteConnection, System.Data.SQLite" />
<connectionString name = "DbConn" value="Data Source=C:[FilePath]\DebugLog.db;Synchronous=Off " />
<commandText value="INSERT INTO debug (Date, Level, Logger, Message) VALUES (@Date, @Level, @Logger, @Message)" />
<immediateFlush value="true" />
<parameter>
<parameterName value="@Date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="@Level" />
<dbType value="String" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="@Logger" />
<dbType value="String" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="@Message" />
<dbType value="String" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="sqlite-appender" />
</root>
</log4net>
I put on true the debug flag in the config file and I get this thrace:
log4net:ERROR [AdoNetAppender] ErrorCode: GenericFailure. Exception while writing to database
System.ArgumentOutOfRangeException: El índice estaba fuera del intervalo. Debe ser un valor no negativo e inferior al tamaño de la colección.
Nombre del parámetro: index
en System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
en System.Data.SQLite.SQLiteParameterCollection.GetParameter(Int32 index)
en System.Data.SQLite.SQLiteParameterCollection.GetParameter(String parameterName)
en System.Data.Common.DbParameterCollection.System.Data.IDataParameterCollection.get_Item(String parameterName)
en log4net.Appender.AdoNetAppenderParameter.FormatValue(IDbCommand command, LoggingEvent loggingEvent)
en log4net.Appender.AdoNetAppender.SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
en log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events)
System.ArgumentOutOfRangeException: El índice estaba fuera del intervalo. Debe ser un valor no negativo e inferior al tamaño de la colección.
Nombre del parámetro: index
en System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
en System.Data.SQLite.SQLiteParameterCollection.GetParameter(Int32 index)
en System.Data.SQLite.SQLiteParameterCollection.GetParameter(String parameterName)
en System.Data.Common.DbParameterCollection.System.Data.IDataParameterCollection.get_Item(String parameterName)
en log4net.Appender.AdoNetAppenderParameter.FormatValue(IDbCommand command, LoggingEvent loggingEvent)
en log4net.Appender.AdoNetAppender.SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
en log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events)
When I use FileAppender it works fine I dont know what happens
Aucun commentaire:
Enregistrer un commentaire