> ## Documentation Index
> Fetch the complete documentation index at: https://docs.westyx.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Spring Boot SDK - Logging

> SLF4J logging, the startup summary, and custom NexusLogger sinks in the Spring Boot SDK.

In a Spring Boot application the starter installs `Slf4jNexusLogger`, so the SDK logs through SLF4J to the logger named **`dev.westyx.nexus.NexusClient`** with no setting - wherever your logging configuration sends that logger's level.

```yaml theme={null}
logging:
  level:
    dev.westyx.nexus.NexusClient: INFO    # the default level
    # dev.westyx.nexus.NexusClient: DEBUG # every sync and every stream event
```

A plain `NexusClient.create(...)` without a `logger` is silent, the Java library norm - except for the [startup summary](#the-startup-summary) switch below.

## What the SDK logs

| Level | When |
| - | - |
| `DEBUG` | Every sync (success or 304), every stream event |
| `INFO` | Client ready, the [startup summary](#the-startup-summary), stream connected, fallback to polling, a WIF session refreshed |
| `WARN` | A resource the server [did not deliver](#resources-the-server-did-not-deliver), the environment switched off, a WIF refresh that failed while the session was still valid |
| `ERROR` | A background sync that failed, a stream transport error, an observer callback that threw (with the stack trace) |

```
nexus: client ready (key_type=sk, kind=backend, wif=off, json=jackson3, ttl=PT1M)
nexus: client loaded configs=[database.url, max.items] secrets=[DB_PASSWORD] flags=[new.checkout]
nexus: SSE stream connected
nexus: SSE event=flag.toggled - triggering sync
nexus: sync OK - configs=12 secrets=4 flags=7 key_type=sk kind=backend
nexus: sync 304 Not Modified - cache retained
```

Every message is collapsed to one line before it reaches SLF4J, so no value can end a log record early and forge the next one.

## The startup summary

After the first sync the client logs one `INFO` record naming what it received:

```
nexus: client loaded configs=[database.url, max.items] secrets=[DB_PASSWORD] flags=[new.checkout]
```

Names only, never a value. Each list is sorted and capped at 50 names, with a `+N more` entry after that, so a large service stays one readable line. It is how you confirm from a pod's log which configs, secrets and flags a deployment actually pulled.

| Setup | The summary |
| - | - |
| The starter | Through SLF4J at `INFO` |
| Your own `logger(...)` | Through it, at `info` |
| A plain client with no logger | Not logged; with `WESTYX_NEXUS_LOG_STARTUP=1` in the environment it is written to standard error as one line |

```
westyx-nexus: client loaded configs=[database.url, max.items] secrets=[DB_PASSWORD] flags=[new.checkout]
```

The variable's name is `NexusLogger.LOG_STARTUP_ENV`.

## Resources the server did not deliver

A sync can report resources it left out - a secret that has no value yet (`secret_not_set`), a config whose `{{secret:KEY}}` reference does not resolve (`config_unresolved_secret`). Such a secret or config reads as absent. Each omission is logged as a `WARN` the first time it appears; `client.getSyncErrors()` lists the current ones. `nexus.log-sync-errors=false` (`NexusConfig.logSyncErrors(false)`) keeps the list without the log lines.

```
nexus: the server did not deliver a resource - code=config_unresolved_secret resource_type=config key=database.url secret=DB_PASSWORD detail=...
```

## Secret values never reach the logger

No log record carries a secret's value, the API key or a session token, and the cached snapshot's `toString()` renders counts only. Key names do appear - in the startup summary and in the omission warning. A name identifies what to look up; it is not the credential.

## A custom logger

Register a `NexusLogger` bean and the auto-configuration uses it instead of the SLF4J adapter; for a plain client, pass it to `NexusConfig.builder().logger(...)`.

```java theme={null}
public interface NexusLogger {
    void debug(String message);
    void info(String message);
    default void warn(String message) { info(message); }
    void error(String message, Throwable cause);
}
```

A logger written without `warn` still works: its warnings arrive at `info`.

### A different SLF4J logger name

```java theme={null}
@Bean
public NexusLogger nexusLogger() {
    Logger log = LoggerFactory.getLogger("myapp.nexus");
    return new NexusLogger() {
        @Override public void debug(String m) { log.debug(m); }
        @Override public void info(String m)  { log.info(m); }
        @Override public void warn(String m)  { log.warn(m); }
        @Override public void error(String m, Throwable t) { log.error(m, t); }
    };
}
```

### Silencing the SDK

Set the level instead of writing a logger:

```yaml theme={null}
logging:
  level:
    dev.westyx.nexus.NexusClient: OFF
```

## A logger that throws is contained

A logger whose method throws never fails an SDK operation. Every internal log call is wrapped, so a failing sink - a broken appender, a full disk - is dropped and the read, refresh, `create()` or stream thread that logged carries on. The [stream observer](https://docs.westyx.dev/sdks/spring-boot/stream-observer.md) is contained the same way.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.