LogRecord stores two types of logs.
ILogger logger = SUP101DB.GetLogger();
logger.Debug("Write this string to the log records table");
SUP101DB.SubmitLogRecords();
Query query = new Query();
query.TestCriteria = Sybase.Persistence.AttributeTest.Equal("component", "Customer");
Sybase.Persistence.SortCriteria sortCriteria = new Sybase.Persistence.SortCriteria();
sortCriteria.Add("requestId", Sybase.Persistence.SortOrder.DESCENDING);
query.SortCriteria = sortCriteria;
GenericList<ILogRecord> loglist = SUP101DB.GetLogRecords(query);
This sample code shows how to find the corresponding MBO with the LogRecord and to delete the log record when a record is processed.
private void processLogRecords()
{
Query query = new Query();
GenericList<ILogRecord> logRecords = SUP101DB.GetLogRecords(query);
bool callSync = false;
foreach (ILogRecord log in logRecords)
{
// log warning message
BenchmarkUtils.AddInfo("log " + log.Component + ":"
+ log.EntityKey
+ " code:" + log.Code
+ " msg:" + log.Message);
if (log.Component.Equals("Customer"))
{
long surrogateKey = Convert.ToInt64(log.EntityKey);
Customer c = Customer.Find(surrogateKey);
if (c.IsPending)
{
c.CancelPending();
}
log.Delete();
log.SubmitPending();
callSync = true;
}
}
if (callSync)
{
SUP101DB.BeginSynchronize(null, null);
}
}