# ng2-logger

> isomorphic logger for browser/server in typescript

Latest version **21.0.76** (published 2026-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng2-logger
pnpm add ng2-logger
yarn add ng2-logger
bun add ng2-logger
```

Provides the commands `ng2-logger`, `ng2-logger-debug`, `ng2-logger-debug-brk`.

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 21.0.76 |
| Published | 2026-11-15 |
| First published | 2016-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 6.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 60 |
| Author | Dariusz Filipiak |
| Maintainers | darekf77 |
| Keywords | isomorphic, logger, logging, logowanie, log, typescript |

## Links

- npm: https://www.npmjs.com/package/ng2-logger
- Repository: https://github.com/darekf77/ng2-logger
- Homepage: https://github.com/darekf77/ng2-logger#readme
- Issues: https://github.com/darekf77/ng2-logger/issues
- npm.io page: https://npm.io/package/ng2-logger

## Dependencies (5)

- [chalk](https://npm.io/package/chalk.md) ^2.3.2
- [json5](https://npm.io/package/json5.md) ~2.2.3
- [tnp-core](https://npm.io/package/tnp-core.md) ~21.0.0
- [randomcolor](https://npm.io/package/randomcolor.md) ^0.5.3
- [json-stringify-safe](https://npm.io/package/json-stringify-safe.md) ^5.0.1

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 21.0.76 (latest) — 2026-11-15
- 21.0.75 — 2026-11-12
- 21.0.74 — 2026-11-10
- 21.0.73 — 2026-11-08
- 21.0.72 — 2026-11-04
- 21.0.71 — 2026-10-31
- 21.0.70 — 2026-10-31
- 21.0.69 — 2026-10-29
- 21.0.68 — 2026-10-27
- 21.0.67 — 2026-10-18
- 21.0.66 — 2026-10-18
- 21.0.65 — 2026-10-17
- 21.0.64 — 2026-10-13
- 21.0.63 — 2026-10-12
- 21.0.62 — 2026-10-11
- … 353 more at https://npm.io/package/ng2-logger/versions

## README

## taon-logger (ng2-logger) ##

- Part of [taon.dev](https://github.com/darekf77/taon)
- Isomorphic Logger for TypeScript and JavaScript apps.
- Purpose:
  + usefull/elegant backend/frontend logger

You can use this logger in your apps with **any**
TS/JS framework.

## ⚠️ Deprecation notes Level.__NOTHING  ⚠️
```ts
// Level.__NOTHING is now gone..⚠️

const log = Log.create('my module or file',Level.__NOTHING); // ❌

// USE INSTEAD

const log = Log.create('my module or file', Level.WARN, Level.ERROR); // ✅

// this will should you important warning and errors for development
// and in production to hide all ng2-logger logs use:

Log.disableAllLogs(); // ✅

```

## How to use ng2-logger 🚀

See what is going on in your app!

Now chrome console logs are full of colors!

![Modules marked](image-fe.png)

See nice server logs:

![Modules marked](image-be.png)


To install package run:
```bash
npm install ng2-logger --save
```  

First import proper version for your environment:

Nodejs server (or any taon's lib/app):  

```ts
import { Log, Level } from  'ng2-logger/lib'
// commonjs
```

or Browser: 

```ts
import { Log, Level } from  'ng2-logger/browser'  
// esm version for browser

```

## Usage:  

In your file:

```ts
# all logs allowed to be visible
const  log  =  Log.create('books');
```

or if you wanna just log errors and warnings :

```ts
# only error and warn logs allowed to be visible
const  log  =  Log.create('books',
 Level.ERROR,
 Level.WARN,
);

```

'books' shoould be class, module or anything inside
 current *.ts/*.js file.

  
You can also assign static color to specific module in application:

```ts
log.color  =  'red';
```

After inited **log** you are able to start debugging:

```ts
log.d('object',obj) // console.log

log.er('object',obj) // console.error

log.i('object',obj) // console.info

log.w('object',obj) // console.warn

```

or

```ts

log.debug('object',obj) // console.log

log.error('object',obj) // console.error

log.info('object',obj) // console.info

log.warn('object',obj) // console.warn

```


**Production mode**
-------------------  

You will not see anyting in production mode:

```ts
import {Log} from 'ng2-logger/browser'

// disable all ng2-logger logs 
Log.disableAllLogsPermanetly();
// without possibility of enabling it again

// OR

// disable all logs, but 
Log.disableAllLogs();
// Log.enableAllLogs and enable it again
Log.enableAllLogs()
```

// your app code with console and ng2-logger logs

  
  
  

**Selective debug - global settings**

-------------------


Optionally specify what you wanna see in yours debug console.


```ts

Log.onlyModules('src:books', 'src:records', 'src:page:login');

Log.onlyLevel(Level.ERROR,Level.INFO);

```

  

**Specifying `onlyModules` as regular expression(s)**

-------------------

  

In the above example you'll notice `module:books` and `module:records` were specified.

you might be using such syntax for namespace hierarchy etc. You may also pass in one or more regular

expression string(s) to the `onlyModule` function to specify a selection of modules you wish

to show, for instances those whose name begins with `src`:

  

```ts
Log.onlyModules( new  RegEx('^.src') );
```

---
_Source: https://npm.io/package/ng2-logger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
