# @webdevadammalej/express-logger

> Express logger

Latest version **1.0.7** (published 2022-05-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install @webdevadammalej/express-logger
pnpm add @webdevadammalej/express-logger
yarn add @webdevadammalej/express-logger
bun add @webdevadammalej/express-logger
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2022-05-02 |
| First published | 2022-04-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | WebDevAdamMalej |
| Maintainers | adammalejwebdev |
| Keywords | express, Express, logger, Logger |

## Links

- npm: https://www.npmjs.com/package/@webdevadammalej/express-logger
- Repository: https://github.com/MalejAdam/express-logger
- Homepage: https://github.com/MalejAdam/express-logger#readme
- Issues: https://github.com/MalejAdam/express-logger/issues
- npm.io page: https://npm.io/package/@webdevadammalej/express-logger

## Dependencies (6)

- [express](https://npm.io/package/express.md) ^4.17.3
- [winston](https://npm.io/package/winston.md) ^3.7.2
- [@types/winston](https://npm.io/package/@types/winston.md) ^2.4.4
- [express-winston](https://npm.io/package/express-winston.md) ^4.2.0
- [express-http-context](https://npm.io/package/express-http-context.md) ^1.2.4
- [@types/express-winston](https://npm.io/package/@types/express-winston.md) ^4.0.0

## 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

- 1.0.7 (latest) — 2022-05-02
- 1.0.6 — 2022-05-02
- 1.0.5 — 2022-05-02
- 1.0.4 — 2022-05-02
- 1.0.3 — 2022-05-02
- 1.0.2 — 2022-04-18
- 1.0.1 — 2022-04-18
- 1.0.0 — 2022-04-18

## README

# Express Logger

## Installation

npm

```bash
npm install @webdevadammalej/express-logger
```

yarn

```bash
yarn add @webdevadammalej/express-logger
```

## Usage

```typescript
import { logger } from "@webdevadammalej/express-logger";

logger.info("It is simple info log");
logger.error("It is simple error log");
logger.warn("It is simple warn log");
```

## Description

This logger add to each request requestId (if not already exists), thanks to this, we are able to analyze each request and step by step find potential problem. To see the request id in logs you should install [express-http-context](https://www.npmjs.com/package/express-http-context), [uuid](https://www.npmjs.com/package/uuid) and create middleware like below:

```typescript
import express, { NextFunction, Request, Response } from "express";
import httpContext from "express-http-context";
import { v4 } from "uuid";

const router = express.Router();

export const requestId = router.use(
  (req: Request, res: Response, next: NextFunction) => {
    httpContext.set("request-id", v4());
    next();
  }
);
```

This middleware add to each log request-id parameter and print something like this

```bash
error: It is simple error log {"label":"client-app","requestId":"8cdb8011-571a-4b6d-91be-4c54cc57637a","timestamp":"2022-05-02 17:34:56"}
```

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