Skip to content

Centralized logging. It is used to setup a server and a clients. Clients are able to send the logs to the server. Server will store the logs in different files based on its category.

Notifications You must be signed in to change notification settings

KumarManoj-S/remote-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 = require('central-logger').Server;

//create the server
var server = new Server(
	'127.0.0.1', 		//host
    3500			//port
);

//set up the transport location
server.addTransports('/var/log/mydirectory/');

server.listen();

start the server,

node server.js

set up your client apps that sends the log or info to the remote server :

const Client = require('central-logger').Client;

//category
const MODULE1 = 'module1';
const MODULE2 = 'module2';

//create the client logger
var logger = new Client('127.0.0.1', 3500);

Afterwards just log as usual:

logger.log("info", "foo", MODULE1);
logger.log("warn", "bar", MODULE2);

It will send the log to the central server. The syntax for the log method is ,

log(level, message, category);

and then on your remote server you can check the logged files,

cat /var/log/mydirectory/MODULE1.log

{"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'

About

Centralized logging. It is used to setup a server and a clients. Clients are able to send the logs to the server. Server will store the logs in different files based on its category.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published