2022

Page tree
Skip to end of metadata
Go to start of metadata

Every AppCode should log the Open, Read, Write and Set Context operations. So that, the results can be visible in the DBSync LogViewer. Note that, DBSync runs in the scheduled batch mode. To view the results, it is important to view the LogViewer that shows the log traces of all the syncs completed and running.

To add the Logger, we need to add the following code: 

1. In the Service class, that implements ApiCode, import java.util.Logger.

2. Instantiate the Logger instance, static Logger logger = Logger.getLogger(MyDummyService.class.getName()).

3. For logging the normal execution, you need to use LogLevel as info. For example, in the Read, Write and open methods, we need to keep a log trace.logger.log(Level.INFO, "MyDummyService.readMyFirst Called: for Query:" + filter.name).

4. For logging unhandled errors, that could be unhandled exception, we need to use the LogLevel as SEVERE. In this case 'e' is the exception thrown.logger.log(Level.SEVERE, "Error while executing method. MyDummyService:readMyFirst", e);

5. In case of Write operation, there are scenarios where the integration runs partially with some errors while in the sync process. In such a situation it is important that we return the errors as a SaveResult error rather than just logging it as an exception. For example, a snippet of code, in the following 'Create Your First Program', shows how to handle an empty input list error.

  • No labels