By default logging is disabled when processing documents but product provides a way to save the log with embedded implementation to save events to console and file.
There is an interface that we can utilize:
ILogger - defines the interface for logging different process event like errors, warnings and information messages (traces).
There are classes that we can utilize:
ConsoleLogger - defines the methods that are required for logging to console.
FileLogger - defines the methods that are required for logging to file.
There are 3 types of messages in the log file:
Error - for unrecoverable exceptions
Warning - for recoverable/expected/known exceptions
Trace - for general information
Logging to File
In this example, we’ll log into the file so we need to use FileLogger class.
// Create logger and specify the output fileFileLoggerfileLogger=newFileLogger("output.log");// Create SignatureSettings and specify FileLoggervarsettings=newSignatureSettings(fileLogger);using(varsignature=newSignature("sample.docx",settings)){varoptions=newQrCodeSignOptions("JohnSmith");// sign document to filesignature.Sign(outputFilePath,options);}
Logging to Console
In this example, we’ll log into the console so we need to use ConsoleLogger class.
// Create logger and specify the output filevarconsoleLogger=newConsoleLogger();// Create SignatureSettings and specify ConsoleLogger instancevarsettings=newSignatureSettings(consoleLogger);using(varsignature=newSignature("sample.docx",settings)){varoptions=newQrCodeSignOptions("JohnSmith");// sign document to filesignature.Sign(outputFilePath,options);}
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.