Front-end logs explore a

Source: Internet
Author: User

Logging is a good thing in programming, often helping us keep track of how the code works, and logging helps us maintain and manage our projects.

Generally our log on the service side, the method to get the log is also very simple, directly using log4 such a library can be very good to complete the required tasks. However, in special cases we may need B/s architecture system to leave us a front-end log. Here's a discussion of one or two.

The client may be our unknown scope first. We'll discuss this later. First, we discuss the logs of the client within our control range. Internal systems such as process systems within the company.

If your company is not practicing outside the network internal system. Use IE browser as the main browser. You can try to use IE's own ActionX control to leave a front-end operation log on the client. Because this plugin allows us to use scripts to manipulate some local files.

First, open IE browser, Internet Options > Security > Custom Level >activex controls and plug-ins are set to Enabled.

Second, use the script to invoke the ActiveX control. The following methods:

Log method
function jslog (message, option) {
try{
var forappending = 8;
var strfile = "D://softjslog" + New Date (). Format ("yyyy-mm-dd") + ". txt";
var objFSO = new ActiveXObject ("Scripting.FileSystemObject");
Check if the file exists
if (objfso.fileexists (strfile)) {
Open a text file
objstream = objFSO.OpenTextFile (strfile, ForAppending, True, false);
Writing string data
if (option = = "1") {
Objstream.writeline (Message + "Start time:" + new Date (). Format ("Yyyy-mm-dd hh:mm:ss"));
}
else {
Objstream.writeline (message + "End time:" + new Date (). Format ("Yyyy-mm-dd hh:mm:ss"));
}
objStream.Close (); Close File
}
else {
var objstream = objFSO.CreateTextFile ("D://softjslog" + New Date (). Format ("yyyy-mm-dd") + ". txt", true);
Writing string data
if (option = = "1") {
Objstream.writeline (Message + "Start time:" + new Date (). Format ("Yyyy-mm-dd hh:mm:ss"));
}
else {
Objstream.writeline (message + "End time:" + new Date (). Format ("Yyyy-mm-dd hh:mm:ss"));
}
objStream.Close (); Close File
}
}
catch (E)
{
Alert (e);
}
}

Third, call the JS method to leave a log.

Locate the client's path in the analysis log.

Front-end logs explore a

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.