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/