NET Logging Library
Database - OLEDB
Basic Tasks > Database - OLEDB

The OleDbTarget logs to an OLEDB database.  It automatically discards oldest entries after reaching a default of 10,000 log messages.  This behavior can be overridden.  Although rolling is supported, the database table will need to be created manually.

The default table name is tblLog. Here are the column names and types:
LogDate OleDbType.DBTimeStamp
Message OleDbType.VarChar
Additional OleDbType.VarChar   
ElapsedMilliseconds OleDbType.Decimal
LogLevel OleDbType.VarChar, 50
MachineName OleDbType.VarChar, 100
UserName OleDbType.VarChar, 100
ProcessName OleDbType.VarChar, 100
CallingMethod OleDbType.VarChar, 255
LineNumber OleDbType.VarChar, 100

 

It has these properties that can be configured:


 

//Example runtime configuration, can also use log.config, app.config, or web.config
Log.ResetConfiguration();

OleDbTarget target = new OleDbTarget();
target.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Work\Documents\database.mdb;User Id=admin;Password=;";
target.TableName = "LogTable";
//Set to zero to not discard max entries
target.MaxEntries = 10000;
Log.Config.Targets.Add(target);

Log.Debug("This is a test");