First of all, you should know that this Logger is suitable for projects using .Net framework 4.7.2+
To use this logger please follow these steps:
To use this logger please follow these steps:
- Install SQLiteRequestResponseLogger Nuget Package.
- Download log file from this link.
- In your configuration file (web.config) please add the following App Settings:
- LiteRequestResponseLogFilePath: Path of Log file that you downloaded with respect to project folder. Make sure to add this key to avoid exceptions.
- <add key="LiteRequestResponseLogFilePath" value="<Path-to-log-file>"/>
- LiteLogsCount: Number of logs you want to view in one page. If you don't add this key, default value of 20 log will be viewed.
- <add key="LiteLogsCount" value="<number-of-logs>"/>
- LiteLogPassword: Password to access logs page. Make sure to add this key as logs page will not be accessible if it is missed.
- <add key="LiteLogPassword" value="<Password>"/>
And now. In your configuration file (web.config), replace this code:
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
</DbProviderFactories>
</system.data>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
</DbProviderFactories>
</system.data>
with the following code:
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
</DbProviderFactories>
</system.data>
Now, we still have one more step to view our logs. In your App_Start\WebApiConfig.cs, in Register function, add the following code:
config.MessageHandlers.Add(new RequestResponseLogHandler());
Now you can view the logs, you shall go to <Application URL>/RequestResponseLogger page of your application. Before you can view the logs you will be redirected to Logger login page. Enter the password that you configured to be redirected to the logs page.
Comments
Post a Comment