LogRecord stores two types of logs.
ILogger logger = SMP101DB.GetLogger(); logger.Debug("Write this string to the log records table"); SMP101DB.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 = SMP101DB.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 = SMP101DB.GetLogRecords(query); 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(); } } SMP101DB.BeginSynchronize(null, null); }
private void processLogs() { Query query = new Query(); GenericList<LogRecord> logRecords = SMP101DB.getLogRecords(query); for(LogRecord log : logRecords) { // log warning message Log.warning("log " + log.getComponent() + ":" + log.getEntityKey() + " code:" + log.getCode() + " msg:" + log.getMessage()); if (log.getComponent().equals("Customer")) { long surrogateKey = Long.parseLong(log.getEntityKey()); Customer c = Customer.find(surrogateKey); if (c.isPending()) { c.cancelPending(); } // delete the LogRecord after it is processed log.delete(); log.submitPending(); } }SAP Mobile Server is responsible for deleting client log records uploaded by the application. These application logs are used for audit and/or support services. Determine and set the retention policy from SAP Control Center after consulting with the application's developers. If there are multiple applications using the same package, retain them based on the maximum required time for each application. Client log records are removed that are outside the retention window, and deleted records removed from the client database the next time the application synchronizes. See Improve Synchronization Performance by Reducing the Log Record Size in Troubleshooting for details about reducing the Log Record size.