---
source_url: https://www.pubnub.com/docs/sdks/windows-c/logging
title: Logging for Windows C SDK
updated_at: 2026-05-20T11:08:41.479Z
sdk_name: PubNub Windows C SDK
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Logging for Windows C SDK

PubNub Windows C SDK

This page explains how to configure logging in the PubNub Windows C Software Development Kit (SDK) using the C-core logging system.

## How to enable logging

`C-core` has a simple & efficient, yet flexible logging system. There are several levels from which to choose. Also, the user can set the function that will do the actual writing of data to an output.

| Log Level | Preprocessor Symbol | Description |
| --- | --- | --- |
| none | `PUBNUB_LOG_LEVEL_NONE` | all checks disabled |
| errors | `PUBNUB_LOG_LEVEL_ERROR` | only errors reported |
| warnings | `PUBNUB_LOG_LEVEL_WARNING` | ignored invalid conditions are reported, too |
| regular | `PUBNUB_LOG_LEVEL_INFO` | significant events reported, too |
| debug | `PUBNUB_LOG_LEVEL_DEBUG` | various reports useful in debugging reported, too |
| detail | `PUBNUB_LOG_LEVEL_TRACE` | all logs enabled (compiled in) |

To choose a level, define preprocessor symbol `PUBNUB_LOG_LEVEL` to one of the symbols from the table above. If you don't define it, the default used is `PUBNUB_LOG_LEVEL_INFO`.

You will see that some of our samples `Makefiles` define this symbol and some don't, depending on their purpose.

Keep in mind that debug & detail levels produce a lot of output that is hard to decypher by the uninitiated. So, it's best to use them only when looking for causes of some bugs - for example, if you report a suspected issue to Pubnub support.

Even though `C-core` logging system is designed for its own purpose, you're free to use it in your code too, if it suits your needs. The interface is in the `pubnub_log.h header`.

The actual writing of the log reports to an output is done by using the preprocessor macro `PUBNUB_LOG_PRINTF` - define it to have printf-like semantics. If you don't define this symbol, the default used is `printf`. For example, here's a simple way to define a function that will output (append) to a file:

```c
int my_logger(char const *fmt, ...)
{
    va_list args;
    int result;
    FILE *f = foppen("mylog.txt", "at");
    if (NULL == f) {
        return -1;
    }
    va_start(args, fmt);
    result = vfprintf(f, fmt, args);
    va_end(args);
    fclose(f);

    return result;
}
```

At some header or in the `makefile` or `project` define `PUBNUB_LOG_PRINTF` to this function, for example:

```c
#define PUBNUB_LOG_PRINTF my_logger
```