Skip to content

czbone/express-log-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

# npm
npm install
  1. Setup

Edit .env file:

MONGO_URL=mongodb://localhost:27017/sampleDB
  1. Launch server

If using VSCode, show the Run and Debug view and launch Start server from Debugging start menu. If using command, input below.

# 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
  1. Build application:
# yarn
yarn build

# npm
npm run build
  1. Launch application:
# yarn
yarn start

# npm
npm start

License

MIT

Releases

No releases published

Packages

 
 
 

Contributors