NET Logging Library
Database - MS Access
Basic Tasks > Database - MS Access

The MsAccessTarget uses and OLEDB connection string to connect to your Microsoft Access database.  It automatically creates a logging table on startup with the name of tblLog if it does not exist.  It automatically discards oldest entries after reaching a default of 10,000 log messages.  This behavior can be overridden.

 

It has these properties that can be configured:

tblLog Columns (Automatically Created)
LogID COUNTER CONSTRAINT PrimaryKey PRIMARY KEY NOT NULL
LogDate datetime NOT NULL
Message Memo NOT NULL
Additional Memo NOT NULL
ElapsedMilliseconds Double  NOT NULL
LogLevel Text(50) NOT NULL
MachineName Text(100) NOT NULL
UserName Text(100) NOT NULL
ProcessName Text(100) NOT NULL
CallingMethod Text(255) NULL
LineNumber Text(100) NOT NULL

 

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

MsAccessTarget target = new MsAccessTarget();
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");