Skip to main content
You are viewing Pre-Alpha documentation.
Vuetify0 Logo
Theme
Mode
Accessibility
Vuetify
Vuetify One

Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

useLogger

The useLogger composable provides a flexible, adapter-based logging system for Vue applications. It supports multiple log levels, runtime enable/disable toggling, and integrates seamlessly with popular logging libraries like Consola and Pino through a simple adapter pattern.


Intermediate97.6% coverageMar 3, 2026

Installation

Install the Logger plugin in your app’s entry point:

main.ts
import { createApp } from 'vue'
import { createLoggerPlugin } from '@vuetify/v0'
import App from './App.vue'

const app = createApp(App)

app.use(
  createLoggerPlugin({
    level: 'debug',
    prefix: '[MyApp]',
  })
)

app.mount('#app')

Usage

Once the plugin is installed, use the useLogger composable in any component:

vue
<script setup lang="ts">
  import { useLogger } from '@vuetify/v0'

  const logger = useLogger()

  logger.info('Component mounted')
  logger.debug('Debug information', { userId: 123 })
  logger.warn('Warning message')
  logger.error('Error occurred', new Error('Something went wrong'))
</script>

<template>
  <div>
    <h1>Check the console for logs</h1>
  </div>
</template>

Architecture

useLogger uses the plugin pattern with a log adapter:

Logger Plugin

Use controls to zoom and pan. Click outside or press Escape to close.

Logger Plugin

Reactivity

The logger uses internal reactive state for level and enabled, but exposes only functions. There are no reactive properties — all interactions are through imperative methods.

API Reference

The following API details are for the useLogger composable.

Functions

createLogger

(options?: LoggerOptions) => E

Creates a new logger instance.

createLoggerContext

<_E>(_options?: LoggerContextOptions | undefined) => ContextTrinity<_E>

createLoggerPlugin

(_options?: LoggerContextOptions | undefined) => Plugin

useLogger

<_E>(namespace?: string) => _E

Options

adapter

LoggerAdapter | undefined

level

LogLevel | undefined

prefix

string | undefined

enabled

boolean | undefined

Methods

debug

(message: string, ...args: unknown[]) => void

info

(message: string, ...args: unknown[]) => void

warn

(message: string, ...args: unknown[]) => void

error

(message: string, ...args: unknown[]) => void

trace

(message: string, ...args: unknown[]) => void

fatal

(message: string, ...args: unknown[]) => void

level

(level: LogLevel) => void

current

() => LogLevel

enabled

() => boolean

enable

() => void

disable

() => void
Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/