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

# Logging

> Logging utilities to help you work with logging

# Logging

Nuxt Kit provides a set of utilities to help you work with logging. These functions allow you to log messages with extra features.

Nuxt provides a logger instance that you can use to log messages with extra features.

## `useLogger`

Returns a logger instance. It uses [consola](https://github.com/unjs/consola) under the hood.

### Type

```ts theme={null}
function useLogger(tag?: string, options?: Partial<ConsolaOptions>): ConsolaInstance
```

### Parameters

**`tag`**: A tag to suffix all log messages with, displayed on the right near the timestamp.

**`options`**: Consola configuration options.

### Usage

```ts theme={null}
import { defineNuxtModule, useLogger } from '@nuxt/kit'

export default defineNuxtModule({
  setup(options, nuxt) {
    const logger = useLogger('my-module')

    logger.info('Hello from my module!')
  },
})
```

## Example with options

```ts theme={null}
import { defineNuxtModule, useLogger } from '@nuxt/kit'

export default defineNuxtModule({
  setup(options, nuxt) {
    const logger = useLogger('my-module', { level: options.quiet ? 0 : 3 })

    logger.info('Hello from my module!')
    logger.success('Module initialized successfully!')
    logger.warn('This is a warning')
    logger.error('Something went wrong')
  },
})
```

## Available log methods

The logger instance provides the following methods:

* `logger.info()` - Log an info message
* `logger.success()` - Log a success message
* `logger.warn()` - Log a warning message
* `logger.error()` - Log an error message
* `logger.debug()` - Log a debug message
* `logger.trace()` - Log a trace message
* `logger.log()` - Log a generic message

## Source

[View source on GitHub](https://github.com/nuxt/nuxt/blob/main/packages/kit/src/logger.ts)
