Getting Started

log4ngx is installed via NPM:

npm install log4ngx --save

Loggers provide access to the methods for logging messages at the required Level. Each class - i.e. component, module or service - will usually define its own Logger which will identify that class within any messages logged via it.

The LogService is the factory with which you instantiate Loggers for each of the components, services, etc, in which you wish to log messages. Behind the scenes, it also orchestrates the dispatch of messages from the Loggers to the appropriate Appenders.

Appenders are responsible for sending log entries to the underlying target or service. Configuration will normally depend on the target/service, but all Appenders are configured with the layout format for messages logged to them. Applications are unlikely to use or reference Appenders directly.

The LogService is configured using an instance of the LogServiceConfig, typically created in your application's main module. The configuration defines the parameters used with each Appender and how each Appender relates to the various Loggers.

The configuration is defined using the LogServiceConfig interface. This can be done directly within main.ts and passed into the providers.

Alternatively, you can use environment-specific configurations (see environment-specific configurations) which would allow you to log 'debug'-level statements in development, but only 'info'-level and above in production, for example.

See Configuration for more information.