Using Log. io in Node. js to monitor logs in the browser in real time (equivalent to the tail-f command) _ node. js

Source: Internet
Author: User
This article mainly introduces Node. use Log. js. io monitors logs in the browser in real time. io is equivalent to the tail-f command, but it is more powerful. If you need it, you can refer to it. Today, I took the time to browse the node. js, haha, read an entry of the article (http://www.nodebeginner.org/index-zh-cn.html), Self feeling is getting started, but inside a sentence, very feeling:

The Code is as follows:


However, these are all front-end technologies. Even if you want to enhance the page, using jQuery always makes you feel great, at last, you are a JavaScript user, not JavaScript developers. Then, how cool is the emergence of Node. js and server-side JavaScript? So you think it's time to pick up the familiar and unfamiliar JavaScript again. But don't worry. Writing Node. js applications is one thing; understanding why they are written in this way means you need to understand JavaScript. This is a real game.
Yes, this time it is about to be a real game ..

In other words, to see a good thing log. io, the official explanation is:

The Code is as follows:


Real-time log monitoring in your browser
Powered by node. js + socket. io

For real-time log monitoring, we may think of tail-f and log. io in linux, which is more powerful than tail-f. This is also a C/S architecture.

The following is a demo:

1. Installation

This thing, depending on nodejs, we first install nodejs, refer to the official installation method :( http://nodejs.org/download)

Here I use the brew Installation Method for mac:

The Code is as follows:


Brew install nodejs

Or use yum:

The Code is as follows:


Yum install nodejs

Then we can use npm to install log. io.

The Code is as follows:


Npm install-g log. io -- user "chenqing"

After installation, start the server (no configuration is required ):

The Code is as follows:


Log. io-server

Then configure the client

The Code is as follows:


Vim ~ /. Log. io/harvester. conf

Exports. config = {
NodeName: "application_server ",
LogStreams :{
Test :[
"/Users/chenqing/test. log"
]
},
Server :{
Host: '0. 0.0.0 ',
Port: 28777
}
}

Start the client: log. io-harvester

Let's test:

First, under the command line

The Code is as follows:


[Chenqing @ Qing ~ ] For I in {1 .. 1000}; do echo 'date'> test. log; done


Open your browser: http: // localhost: 28778/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.