LogoLogo
v3.5
v3.5
  • Introduction
  • Getting Started
    • Why
    • Installation
  • Concepts
    • Introduction
    • Store
    • Actions
    • State
    • Select
  • API
    • @Action
    • Actions(Stream)
    • Init Actions
    • Module
    • of-action
    • @Select
    • @Selector
    • @State
    • Store
  • Advanced
    • State Operators
    • Options
    • Lazy Loading
    • Sub States
    • Cancellation
    • Action Handlers
    • Composition
    • Error Handling
    • Life-cycle
    • Meta Reducers
    • Shared State
  • Recipes
    • Authentication
    • Caching
    • Unit Testing
    • Style Guide
  • Plugins
    • Introduction
    • CLI
    • Logger
    • Devtools
    • Storage
    • Forms
    • Web Socket
    • Router
    • HMR
  • NGXS Labs
    • Introduction
    • Emitter
    • Immer adapter
    • Dispatch decorator
  • Community
    • FAQ
    • Resources
    • Contributors
    • Contributing
    • Sponsors
  • Changelog
Powered by GitBook
On this page
  • Installation
  • Usage
  • Options
  • Notes
  1. Plugins

Logger

A simple console log plugin to log actions as they are processed.

Installation

npm install @ngxs/logger-plugin --save

# or if you are using yarn
yarn add @ngxs/logger-plugin

Usage

Add the NgxsLoggerPluginModule plugin to your root app module:

import { NgxsModule } from '@ngxs/store';
import { NgxsLoggerPluginModule } from '@ngxs/logger-plugin';

@NgModule({
  imports: [
    NgxsModule.forRoot([]),
    NgxsLoggerPluginModule.forRoot()
  ]
})
export class AppModule {}

Options

The plugin supports the following options passed via the forRoot method:

  • logger: Supply a different logger, useful for logging to backend. Defaults to console.

  • collapsed: Collapse the log by default or not. Defaults to true.

  • disabled: Disable the logger during production.

Notes

You should always include the logger as the last plugin in your configuration. For instance, if you were to include logger before a plugin like the storage plugin, the initial state would not be reflected.

PreviousCLINextDevtools

Last updated 6 years ago