Logging

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Viewer MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →

By default, logging is disabled when rendering documents. You can log to a file.

To log to a text file, use the FileLogger class.

The log contains the following four types of messages:

  • Error means unrecoverable exceptions
  • Warning means recoverable/expected exceptions
  • Debug means debug information
  • Trace means general information

The following code snippet shows how to log to a file using the FileLogger class:

import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.ViewerSettings;
import com.groupdocs.viewer.logging.FileLogger;
import com.groupdocs.viewer.options.HtmlViewOptions;
import com.groupdocs.viewer.options.ViewOptions;
// ...

// 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.pdf", viewerSettings)) {
    ViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources("result.html");

    viewer.view(viewOptions);
}

The following image shows the output.log file: