Central Logger
Central Logger is a tiny library for streaming the logs and info about the node application to the remote server. It is working using 'fire and forget' protocol.
Install
Available via npm.
npm install central-logger
Usage
Set up your remote central server :
var Server = Server; //create the servervar server = '127.0.0.1' //host 3500 //port; //set up the transport locationserver; server;
start the server,
node server.js
set up your client apps that sends the log or info to the remote server :
const Client = Client; //categoryconst MODULE1 = 'module1';const MODULE2 = 'module2'; //create the client loggervar logger = '127.0.0.1' 3500;
Afterwards just log as usual:
logger;logger;
It will send the log to the central server. The syntax for the log method is ,
;
and then on your remote server you can check the logged files,
cat /var/log/mydirectory/MODULE1log "level":"info""message":"foo""timestamp":"2018-07-05T10:36:41.357Z"
If you don't mention any category while logging like logger.log("info", "foo");
it will log them into the deafult file 'error.log'