기술 이전 완료하여 주소 지웠습니다.

프로젝트 엉뚱하게 완료.

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

var requestip = require('request-ip');

function _(request, response) 에 

 

console.log(requestip.getClientIp(request));

175.223.39.36

175.223.39.36
175.223.39.36
175.223.39.36
175.223.39.36
175.223.39.36
175.223.39.36
175.223.39.36
175.223.39.36
175.223.39.36

 

하면 찍히고

 

https://stackoverflow.com/questions/54654946/how-to-write-console-log-to-a-file-instead

 

How to write console.log to a file instead

Now I show the information using: console.log (kraken.id, markets) However, I want to write all the information that goes to the console to a file instead. How can that be done by completing the ...

stackoverflow.com

https://mungmungdog.tistory.com/34

 

node.js winston 적용하기(node.js logger)

node.js winston 적용하기 요새 node.js 로의 개발을 하게 되면서 테스트 및 디버깅, 통계 등의 사용을 위해 로그를 남겨야할 필요성을 느껴 추가하게 되었습니다. 기존의 console.log() 를 사용해도 내용��

mungmungdog.tistory.com

 

 

const fs = require('fs');

const path = require('path');

const url = require('url');

var httpServer = require('http');

var requestip = require('request-ip');

const winston = require('winston');

require('winston-daily-rotate-file');

require('date-utils');

 

const logger = winston.createLogger({

    level: 'debug',

    transports: [

        new winston.transports.DailyRotateFile({

            filename : 'log/system.log',

            zippedArchive: true,

            format: winston.format.printf(

                info => `${new Date().toFormat('YYYY-MM-DD HH24:MI:SS')} [${info.level.toUpperCase()}] - ${info.message}`)

        }),

        new winston.transports.Console({

            format: winston.format.printf(

                info => `${new Date().toFormat('YYYY-MM-DD HH24:MI:SS')} [${info.level.toUpperCase()}] - ${info.message}`)

        })

    ]

});

 

module.exports = logger;

 

const ioServer = require('socket.io');

 

.

.

.

//console.log(requestip.getClientIp(request));

    logger.debug(requestip.getClientIp(request));

 

요렇게 처리하면 된다.

 





 

+ Recent posts