Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 
Add your own
alternative version

log4Net and SQLite

, 14 Jun 2012 Apache
This article explains how to work with log4Net and SQLite.
log4net.zip
log4net.db
log4NetSQlite.zip
log4NetSQlite
log4Net
log4NetExample.suo
App_Data
log4net.db
bin
log4net.dll
log4net.pdb
log4NetExample.dll
log4NetExample.pdb
System.Data.SQLite.dll
System.Data.SQLite.pdb
Global.asax
log4NetExample.csproj.user
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
log4NetExample.dll
log4NetExample.pdb
ResolveAssemblyReference.cache
TempPE
Properties
<?xml version="1.0"?>
<configuration>
	<configSections>
		<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net, Version=1.2.11.0, Culture=neutral"/>
	</configSections>
	<appSettings>
    <!-- Set true if you want to trace the internal log for log4Net, see the  system.diagnostics for more details-->
    <add key="log4net.Internal.Debug" value="false"/>
  </appSettings>
	<log4net debug="true">
		<appender name="sqlite" type="log4net.Appender.AdoNetAppender">
			<bufferSize value="1"/>
			<connectionType value="System.Data.SQLite.SQLiteConnection, System.Data.SQLite, Version=1.0.81.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"/>
			<connectionString value="data source=|DataDirectory|\log4net.db;Synchronous=Off "/>
			<commandText value="INSERT INTO log4net(appdomain, aspnetcache, aspnetcontext, aspnetrequest, aspnetsession, [date], exception, file, identity, location, level, line, logger, message, method, ndc, property, stacktrace, stacktracedetail, [timestamp], thread, type, username, utcdate) VALUES (@appdomain, @aspnetcache, @aspnetcontext, @aspnetrequest, @aspnetsession, @date, @exception, @file, @identity, @location, @level, @line, @logger, @message, @method, @ndc, @property, @stacktrace, @stacktracedetail, @timestamp, @thread, @type, @username, @utcdate)"/>
			<parameter>
				<parameterName value="@appdomain"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%appdomain"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@aspnetcache"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%aspnet-cache"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@aspnetcontext"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%aspnet-context"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@aspnetrequest"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%aspnet-request"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@aspnetsession"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%aspnet-session{Usuario}"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@date"/>
				<dbType value="DateTime"/>
				<layout type="log4net.Layout.RawTimeStampLayout"/>
			</parameter>
			<parameter>
				<parameterName value="@exception"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%exception"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@file"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%file"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@identity"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%identity"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@location"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%location"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@level"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%level"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@line"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%line"/>
				</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>
			<parameter>
				<parameterName value="@method"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%method"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@ndc"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%ndc"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@property"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%property"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@stacktrace"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%stacktrace"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@stacktracedetail"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%stacktracedetail"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@timestamp"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%timestamp"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@thread"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%thread"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@type"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%type"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@username"/>
				<dbType value="String"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%username"/>
				</layout>
			</parameter>
			<parameter>
				<parameterName value="@utcdate"/>
				<dbType value="DateTime"/>
				<layout type="log4net.Layout.PatternLayout">
					<conversionPattern value="%utcdate{yyyy-MM-dd HH:mm:ss}"/>
				</layout>
			</parameter>
		</appender>
		<root>
			<level value="ALL"/>
			<appender-ref ref="sqlite"/>
		</root>
	</log4net>
  <system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add
            name="textWriterTraceListener"
            type="System.Diagnostics.TextWriterTraceListener"
            initializeData="C:\temp\log4net.txt" />
      </listeners>
    </trace>
  </system.diagnostics>
  <system.webServer>
		<modules runAllManagedModulesForAllRequests="true"/>
	</system.webServer>
	<system.web>
		<compilation debug="true"/></system.web></configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0

Share

About the Author

Elvin Deras
Program Manager Grupo Leitz
Honduras Honduras
No Biography provided
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 14 Jun 2012
Article Copyright 2012 by Elvin Deras
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid