How to set up logging

By default GroupDocs.Viewer doesn’t write logs when rendering documents but we provide a way to save the log to a file.

The following loggers provided:

There are 4 types of messages that we write to log file

  • error - for unrecoverable exceptions
  • warning - for recoverable/expected exceptions
  • debug - for debug information
  • trace - for maximum detailed messages

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 file
FileLogger fileLogger = new FileLogger("output.log");

// Create ViewerSettings and specify FileLogger
ViewerSettings viewerSettings = new ViewerSettings(fileLogger);

try (Viewer viewer = new Viewer("sample.docx", viewerSettings)) {
    ViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources("result.html");


After running code above output.log file will be created with the similar content:

[TRACE] Rendering into HTML with embedded resources.
[TRACE] Detecting file type by extension.
[TRACE] File type detected successfully: {}.
[TRACE] Opening document.
[TRACE] Applying options.
[TRACE] Converting page 1.
[TRACE] Page 1 conversion completed.
[TRACE] Converting page 2.
[TRACE] Page 2 conversion completed.
[TRACE] Releasing resources