# Custom loggers

To use your own logger with **@node-ts/bus**, create an adapter class by implementing the **Logger** interface. In this example [winston](https://www.npmjs.com/package/winston) is being used

```typescript
import { Logger } from '@node-ts/bus-core'
import winston from 'winston'

export class WinstonLogger implements Logger {

  private winstonLogger: winston.Logger

  constructor (
    name: string // This is the name of the class the logger will be injected into
  ) {
    this.winstonLogger = winston.createLogger({
      format: winston.format.json(),
      defaultMeta: { name }
    })
  }

  debug (message: string, meta?: object): void {
    this.winstonLogger.debug(message, meta)
  }

  trace (message: string, meta?: object): void {
    this.winstonLogger.verbose(message, meta)
  }

  info (message: string, meta?: object): void {
    this.winstonLogger.info(message, meta)
  }

  warn (message: string, meta?: object): void {
    this.winstonLogger.warn(message, meta)
  }

  error (message: string, meta?: object): void {
    this.winstonLogger.error(message, meta)
  }

  fatal (message: string, meta?: object): void {
    this.winstonLogger.crit(message, meta)
  }
}

```

Configure **@node-ts/bus-core** to use your log adapter

```typescript
import { Bus } from '@node-ts/bus-core'
import { WinstonLogger } from './winston-logger'
​
async function run () {
  const bus = await Bus.configure()
    .withLogger((target: string) => new WinstonLogger(target))
    .initialize()
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bus.node-ts.com/guide/loggers/custom-loggers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
