250x250
Notice
Recent Posts
Recent Comments
- Today
- Total
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- mongodb
- RDS
- MYSQL
- TypeScript
- til
- atlas
- single quote
- css
- jsonwebtoken
- moment
- async
- flutter
- Express
- Node.js
- https
- await
- TailwindCSS
- JavaScript
- mongoose
- certbot
- sequelize
- nginx
- clipBehavior
- Nodejs
- Find
- EC2
- double quote
- wil
- findByIdAndDelete
- AWS
Link
Archives
기억 휘발 방지소
[Node.js] morgan 본문
728x90
반응형
morgan은 로그 기록을 남기는 모듈이다. 요청에 대한 정보를 콘솔에 출력한다.
서버로 들어온 요청과 응답을 기록해주는 미들웨어
아래 명령어를 입력하여 설치한다.
npm i morgan
const express = require("express");
const morgan = require("morgan");
...
const app = express();
...
app.use(morgan("dev"));
...
함수의 인자로는 dev, combined, tiny, short, common을 넣어줄 수 있다.
dev는 아래와 같이 결과가 나온다.
GET / 304 3.631 ms - -
combined일 때
::1 - - [06/Sep/2021:06:01:04 +0000] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"
보통 개발시에는 dev를, 배포시에는 combined를 많이 쓴다고한다.
728x90
반응형
'Web > Node.js' 카테고리의 다른 글
[Node.js] express.static (0) | 2021.09.09 |
---|---|
[Node.js] Express (0) | 2021.09.09 |
[Node.js] path, __dirname, __filename (0) | 2021.09.09 |
[Node.js] fs 모듈 (0) | 2021.09.06 |
[Node.js] REPL (0) | 2021.09.01 |