Logging and Diagnostics

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.Comparison 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-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

GroupDocs.Comparison for Python via .NET exposes a small logging API through the groupdocs.comparison.logging namespace. Use it to surface diagnostic messages during development, capture logs in production, or wire the library’s output into your application’s existing logging pipeline.

Console logger

The simplest option is to attach a ConsoleLogger via ComparerSettings when constructing a Comparer. Comparison-time messages are written to standard output:

from groupdocs.comparison import Comparer, ComparerSettings
from groupdocs.comparison.logging import ConsoleLogger

def logging_console():
    settings = ComparerSettings()
    settings.logger = ConsoleLogger()

    with Comparer("./source.docx", settings=settings) as comparer:
        comparer.add("./target.docx")
        comparer.compare("./result.docx")

if __name__ == "__main__":
    logging_console()

source.docx is the source file used in this example. Click here to download it.

target.docx is the target file used in this example. Click here to download it.

Binary file (DOCX, 25 KB)

Download full output

Run the script and you will see GroupDocs.Comparison’s progress messages, warnings, and errors printed to the console.

What ILogger exposes

ConsoleLogger implements the ILogger interface. The interface exposes three method families:

MethodWhen it fires
trace(message)Verbose progress messages (page-by-page, change-by-change)
warning(message)Recoverable issues (missing fonts substituted, format quirks)
error(message)Failures that aborted part of the operation

Each method has _file(path, message) and _string(text, message) overloads — the first arg identifies which document caused the log line.

Note
Custom Python subclasses of ILogger are not yet auto-wrapped by the wheel as of 26.4.0.postN — passing a custom logger raises TypeError: cannot wrap … as ILogger. Use ConsoleLogger and redirect stdout/stderr at the OS level for file capture; a future wheel release will add the callback-adapter wiring for ILogger subclasses.

Writing logs to a file

For now, capture ConsoleLogger output to disk by redirecting the process’s stdout / stderr at the OS level:

python my_comparison.py >> groupdocs-comparison.log 2>&1

Rotate the log file with your usual operating-system tooling (logrotate on Linux, scheduled archival on Windows). On Windows PowerShell:

python my_comparison.py *>> groupdocs-comparison.log

Troubleshooting

If a comparison behaves unexpectedly, enable logging first and re-run the example. The logger will surface load-time warnings (missing fonts, unsupported features in a specific format, malformed XML) that the call-site otherwise swallows.

When opening a support ticket on the forum, include the captured log file alongside the source/target documents and a minimal reproducer — the development team can triage faster with the full diagnostic context.