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