https://github.com/czbone/express-log-sample
Node.js logging sample
https://github.com/czbone/express-log-sample
express logging mongodb mongoose nodejs typescript winston
Last synced: 3 months ago
JSON representation
Node.js logging sample
- Host: GitHub
- URL: https://github.com/czbone/express-log-sample
- Owner: czbone
- License: mit
- Created: 2023-09-28T05:46:36.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-08T05:35:05.000Z (over 2 years ago)
- Last Synced: 2025-01-25T11:26:22.000Z (over 1 year ago)
- Topics: express, logging, mongodb, mongoose, nodejs, typescript, winston
- Language: TypeScript
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nodejs logging example
Multiple purpose logging example on Nodejs express system by customizing winston.
## Features
- Typescript base
- using Winston module
- MongoDB error logging
- logging to console and file(json)
- logging HTTP request context
## Environment
- Node v18.0 above
- MongoDB v6.0
## How to use
1. Install module
```bash
# yarn
yarn install
# npm
npm install
```
2. Setup
Edit `.env` file:
```
MONGO_URL=mongodb://localhost:27017/sampleDB
```
3. Launch server
If using VSCode, show the `Run and Debug` view and launch `Start server` from `Debugging start` menu.
If using command, input below.
```bash
# yarn
yarn dev
# npm
npm run dev
```
Start the development server on http://localhost:3000
with logging files in `logs` directory.
## Production build
1. Edit `.env` file for production:
```
NODE_ENV=production
```
2. Build application:
```bash
# yarn
yarn build
# npm
npm run build
```
3. Launch application:
```bash
# yarn
yarn start
# npm
npm start
```
## License
[MIT](./LICENSE)