---
title: "HTML to PDF file logging diagnostics | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/conversion/html-to-pdf-file-logging-diagnostics/"
md_url: "https://www.nutrient.io/guides/dotnet/conversion/html-to-pdf-file-logging-diagnostics.md"
last_updated: "2026-05-28T01:45:39.246Z"
description: "Learn how to write HTML-to-PDF diagnostic logs to a file using Nutrient .NET SDK."
---

# HTML to PDF file logging diagnostics

Console logging often falls short in production when you need to diagnose HTML-to-PDF conversion issues. File-based logging solves that problem because logs persist after restarts, support post-mortem analysis, and keep standard output clean.

This guide builds on the concepts introduced in the [HTML-to-PDF console logging diagnostics](https://www.nutrient.io/guides/dotnet/conversion/html-to-pdf-logging-diagnostics.md) guide and extends the configuration with a file logging provider. It covers:

- File output configuration

- Rolling file rotation

- Dual-sink logging to both console and file

For a complete reference of log severity levels and log categories emitted by the SDK, refer to the [console logging diagnostics](https://www.nutrient.io/guides/dotnet/conversion/html-to-pdf-logging-diagnostics.md) guide.

## Choose a file logging provider

`Microsoft.Extensions.Logging` doesn’t include a built-in file provider. This guide uses `NReco.Logging.File` [nreco](https://github.com/nreco/logging), which integrates with `LoggerFactory.Create()`.

## Prepare the project

Initialize the SDK and import `NReco.Logging.File` with the standard logging abstractions:

```csharp

using GdPicture14;
using GdPicture.Internal.Globals;
using Microsoft.Extensions.Logging;
using NReco.Logging.File;

LicenseManager licence = new LicenseManager();
licence.RegisterKEY("");

```

## Configure file and console logging

Create an `ILoggerFactory` with:

- `.AddConsole()` for immediate terminal output

- `.AddFile()` for persisted diagnostics

`AddFile()` takes a file path and a callback for rotation settings:

```csharp

using ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
{
    builder.AddFilter("GdPicture.Internal.HTML", LogLevel.Debug).AddConsole().AddFile("html-conversion.log", fileLoggerOpts =>
        {
            fileLoggerOpts.Append = false;
            fileLoggerOpts.FileSizeLimitBytes = 10 * 1024 * 1024;  // 10 MB per file
            fileLoggerOpts.MaxRollingFiles = 3;
        });
});

GdPictureLoggerFactory.SetLogger(loggerFactory);

```

### File rotation options

- **`Append`**
  - Set to `false` to create a fresh log file on each run.
  - Set to `true` to keep adding logs across runs.

- **`FileSizeLimitBytes`**
  - Defines the maximum file size before rotation.
  - When the file reaches the limit, the provider renames it (for example, `html-conversion.log` to `html-conversion.1.log`) and creates a new file.

- **`MaxRollingFiles`**
  - Defines how many rotated files the provider keeps.
  - Older files are deleted to prevent unbounded disk use.

If you need full protocol output for troubleshooting, set the filter to `LogLevel.Trace`. This produces high log volume, so increase `FileSizeLimitBytes` or `MaxRollingFiles` as needed.

## Set up the web browser engine and run the conversion

```csharp

// Uncomment the code below to fetch a chrome headless shell instance, instead of using the local chromium
// GdPictureDocumentUtilities.SetWebBrowserPath(
//     GdPictureDocumentUtilities.FetchLatestChromeHeadlessShell(Environment.CurrentDirectory));

```

If you run HTML conversion inside Docker on Linux, make sure the container is configured for Chrome-based rendering first. Refer to the [running Chrome-based conversions in Docker](https://www.nutrient.io/guides/dotnet/deployment/headless-modes-google-chrome.md) guide.

With file logging configured, all internal SDK events are written to both the console and `html-conversion.log`:

```csharp

using GdPictureDocumentConverter converter = new GdPictureDocumentConverter();
converter.LoadFromHttp(new Uri("https://www.nutrient.io/sdk/dotnet"));
GdPictureStatus status = converter.SaveAsPDF("output.pdf");

if (status == GdPictureStatus.OK)
{
    Console.WriteLine("Conversion completed. Diagnostic logs written to html-conversion.log");
}
else
{
    Console.Error.WriteLine($"Conversion failed with status: {status}. Check html-conversion.log for details.");
}

```

## Review the log file

After conversion completes, `html-conversion.log` contains the diagnostic trace. The file persists after the app exits, so you can review or share it later. The format matches console output:

```

info: GdPicture.Internal.HTML.HtmlConverter[0]
      Loading url https://www.nutrient.io/sdk/dotnet
info: GdPicture.Internal.HTML.HtmlConverter[0]
      Url loaded
info: GdPicture.Internal.HTML.HtmlConverter[0]
      Starting conversion to PDF...

```

## Handle errors

When conversion fails, the log file gives you a full event timeline leading to the failure. This helps with intermittent issues that are hard to reproduce. For details on `GdPictureStatus` return codes, refer to the [handling errors with.NET SDK](https://www.nutrient.io/guides/dotnet/troubleshoot.md) guide.

## Conclusion

File-based logging supports production troubleshooting without changing application behavior or requiring an active terminal session. Rolling file rotation prevents unbounded disk usage, and dual-sink configurations give you both immediate console feedback and persistent file records. For an introduction to HTML-to-PDF diagnostic logging and the full reference of severity levels and log categories, refer to the [console logging diagnostics](https://www.nutrient.io/guides/dotnet/conversion/html-to-pdf-logging-diagnostics.md) guide.
---

## Related pages

- [Convert any image to PDF in C#](/guides/dotnet/conversion/any-image-to-pdf.md)
- [Convert to MS Office from any file in C#](/guides/dotnet/conversion/any-file-to-office.md)
- [Convert DWG or DXF to PDF in C#](/guides/dotnet/conversion/cad-to-pdf.md)
- [Convert bitmap (BMP) to PDF in C#](/guides/dotnet/conversion/bmp-to-pdf.md)
- [Convert emails (MSG/EML) to PDF in C#](/guides/dotnet/conversion/email-to-pdf.md)
- [Embed a font in a Word document](/guides/dotnet/conversion/embed-font-in-word-document.md)
- [Convert Excel to PDF in C#](/guides/dotnet/conversion/excel-to-pdf.md)
- [HTML to PDF logging diagnostics](/guides/dotnet/conversion/html-to-pdf-logging-diagnostics.md)
- [Convert HTML to PDF using C# and .NET](/guides/dotnet/conversion/html-to-pdf.md)
- [Convert HTML to Word in C#](/guides/dotnet/conversion/html-to-word.md)
- [Convert images to PDFs in C#](/guides/dotnet/conversion/image-to-pdf.md)
- [Convert files to PDF in C# .NET](/guides/dotnet/conversion.md)
- [Convert JPG to PDF in C#](/guides/dotnet/conversion/jpg-to-pdf.md)
- [Converting a document from Markdown to PDF format](/guides/dotnet/conversion/markdown-to-pdf.md)
- [Merge and combine multiple files into a PDF in C#](/guides/dotnet/conversion/merge-to-pdf.md)
- [Convert MS Office files to PDFs in C#](/guides/dotnet/conversion/office-to-pdf.md)
- [Convert PDF to bitmap (BMP) in C#](/guides/dotnet/conversion/pdf-to-bmp.md)
- [Convert PDF to Excel in C#](/guides/dotnet/conversion/pdf-to-excel.md)
- [Converting PDF to HTML](/guides/dotnet/conversion/pdf-to-html.md)
- [Convert images to PDFs in C#](/guides/dotnet/conversion/pdf-to-image.md)
- [Convert PDF to JPG in C#](/guides/dotnet/conversion/pdf-to-jpg.md)
- [Converting a document from PDF to Markdown format](/guides/dotnet/conversion/pdf-to-markdown.md)
- [Convert PDF to other images in C#](/guides/dotnet/conversion/pdf-to-other-image.md)
- [Convert PDF to PDF/UA](/guides/dotnet/conversion/pdf-to-pdf-ua.md)
- [Convert PDF to PDF/A](/guides/dotnet/conversion/pdf-to-pdfa.md)
- [Convert PDF to PNG in C#](/guides/dotnet/conversion/pdf-to-png.md)
- [Convert PDF to SVG in C#](/guides/dotnet/conversion/pdf-to-svg.md)
- [Convert PDF to PowerPoint in C#](/guides/dotnet/conversion/pdf-to-powerpoint.md)
- [Convert PDF to TIFF in C#](/guides/dotnet/conversion/pdf-to-tiff.md)
- [Convert PDF to Word in C#](/guides/dotnet/conversion/pdf-to-word.md)
- [Convert PNG to PDF in C#](/guides/dotnet/conversion/png-to-pdf.md)
- [Convert PowerPoint to PDF in C#](/guides/dotnet/conversion/powerpoint-to-pdf.md)
- [Convert RTF to Word in C#](/guides/dotnet/conversion/rtf-to-docx.md)
- [Convert SVG to PDF in C#](/guides/dotnet/conversion/svg-to-pdf.md)
- [Convert RTF to PDF in C#](/guides/dotnet/conversion/rtf-to-pdf.md)
- [Convert text to PDF in C#](/guides/dotnet/conversion/text-to-pdf.md)
- [Convert TIFF to PDF in C#](/guides/dotnet/conversion/tiff-to-pdf.md)
- [Convert to Word, Excel, or PowerPoint in C#](/guides/dotnet/conversion/to-office.md)
- [Converting Word documents with comments to PDF](/guides/dotnet/conversion/word-document-to-pdf-including-comments.md)
- [Converting Word documents to PDF/UA](/guides/dotnet/conversion/word-document-to-pdf-ua.md)
- [Convert Word to PDF in C#](/guides/dotnet/conversion/word-to-pdf.md)

