You can implement ILogger interface from com.groupdocs.redaction.options package. This interface requires to implement three methods:
importcom.groupdocs.redaction.options.ILogger;importjava.util.ArrayList;/**
* <p>
* This is an example of ILogger implementation, tracking count of error messages.
* </p>
*/publicclassCustomLoggerimplementsILogger{privateArrayList<String>_errors;privateArrayList<String>_traces;privateArrayList<String>_warnings;publicbooleanhasErrors(){return_errors.size()>0;}publicCustomLogger(){_errors=newArrayList<String>();_traces=newArrayList<String>();_warnings=newArrayList<String>();}publicvoiderror(Stringmessage){_errors.add(message);}publicvoidtrace(Stringmessage){_traces.add(message);}publicvoidwarning(Stringmessage){_warnings.add(message);}}
Once implemented, you can use it to track error log records:
CustomLoggerlogger=newCustomLogger();finalRedactorredactor=newRedactor(Constants.SAMPLE_DOCX,newLoadOptions(),newRedactorSettings(logger));try{// Here we can use document instance to perform redactions
redactor.apply(newDeleteAnnotationRedaction());if(!logger.hasErrors()){redactor.save();}}finally{redactor.close();}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.