CN109542716B - J2EE platform-based log recording method and user association plug-in - Google Patents
J2EE platform-based log recording method and user association plug-in Download PDFInfo
- Publication number
- CN109542716B CN109542716B CN201811215557.1A CN201811215557A CN109542716B CN 109542716 B CN109542716 B CN 109542716B CN 201811215557 A CN201811215557 A CN 201811215557A CN 109542716 B CN109542716 B CN 109542716B
- Authority
- CN
- China
- Prior art keywords
- user
- name
- plug
- association
- database
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3065—Monitoring arrangements determined by the means or processing involved in reporting the monitored data
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a log recording method and a user associated plug-in based on a J2EE platform, wherein the method comprises the following steps: s1, when the user logs in the web system through the browser, triggering the user associated plug-in to acquire the login information of the user, wherein the login information comprises: user name, IP address and login time; and S2, when the user successfully logs in and accesses various service functions of the web system, triggering the user association plug-in to generate a corresponding log record and storing the log record in the database. According to the log recording method and the user associated plug-in, the user associated plug-in can be used for recording the general operation log without intruding the application, so that the flexibility of log storage is improved, and meanwhile, the tedious and repetitive work is reduced.
Description
Technical Field
The invention relates to the technical field of log collection, in particular to a log recording method based on a J2EE platform and a user association plug-in.
Background
With the rapid development of internet technology, various application programs are gradually converted from an original C/S mode to a B/S mode, and currently, the J2EE platform is mostly adopted in the development of web application programs in enterprises. Due to the cross-platform characteristic of JAVA language, most applications adopt the MVC design pattern based on the J2EE platform, and MVC is: data layer, view layer, control layer.
When web applications are developed, the user operation log is stored as a basic function, the user operation log is generally recorded in a control layer, the traditional log record is basically stored in a database, the flexibility of log storage becomes important along with the increasing importance of big data analysis, meanwhile, the micro service is rapidly developed at any time, more and more modules are independently developed, each module has the log recording function, a general log recording function is designed, and the reduction of complicated and repetitive work becomes more and more important.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a log recording method based on a J2EE platform and a user association plug-in, so that the flexibility of log storage is improved, and the tedious and repetitive work is reduced.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows:
a J2EE platform-based logging method comprises the following steps:
s1, when the user logs in the web system through the browser, triggering the user associated plug-in to obtain the login information of the user, wherein the login information comprises: user name, IP address and login time;
and S2, when the user successfully logs in and accesses various service functions of the web system, triggering the user association plug-in to generate a corresponding log record and storing the log record in a database.
Further, a method for logging based on the J2EE platform as described above, wherein the logging includes: user name, IP address, start time of operation, end time of operation, service name, class name, method name, parameter information.
Further, in the aforementioned logging method based on the J2EE platform, in step S2, the user association plug-in obtains the service name by associating the class name and the method name through a configured dictionary, where the association information is read from a configuration file or the database in a hot loading manner, and the service name includes a log type.
Further, in the logging method based on the J2EE platform as described above, in step S1, the user association plug-in obtains the login information of the user through the login URL or obtains the login information of the user from the session according to the attribute name; the user associated plug-in monitors a session failure method of the middleware, and triggers an action of deleting the login information of the user when the session failure is confirmed.
Further, the J2EE platform-based logging method as described above, before the step S1, further includes:
and putting the user associated plug-in into CLASSPATH parameters of the middleware in an independent jar file mode, modifying a start script of the middleware, adding a java parameter and configuring an agent plug-in.
Further, according to the J2EE platform-based logging method, the database is a mysql database, and before the database is used, the configuration of the jdbc connection mysql database is completed.
The embodiment of the invention also provides a user association plug-in, which is obtained by dynamically modifying java byte codes based on java agent technology, and is used for acquiring login information of a user when the user logs in a web system through a browser, wherein the login information comprises: user name, IP address and login time; and the system is also used for generating a corresponding log record and storing the log record in the database when the user accesses various service functions of the web system after logging in successfully.
Further, a user association plug-in as described above, the log record comprising: user name, IP address, start time of operation, end time of operation, service name, class name, method name, parameter information.
Further, the user association plug-in is specifically configured to obtain the service name through configured dictionary association according to the class name and the method name, where the association information is obtained by reading from a configuration file or the database in a hot loading manner, and the service name includes a log type.
Further, the user association plug-in is specifically configured to obtain login information of a user through a login URL or obtain login information of the user from a session according to an attribute name; the user association plug-in is also used for monitoring a session failure method of the middleware, and when the session failure is confirmed, an action of deleting the login information of the user is triggered.
The invention has the beneficial effects that: according to the log recording method and the user associated plug-in, the user associated plug-in can be used for recording the general operation log without intruding the application, so that the flexibility of log storage is improved, and meanwhile, the tedious and repetitive work is reduced.
Drawings
Fig. 1 is a schematic flowchart of a logging method based on a J2EE platform according to an embodiment of the present invention;
fig. 2 is a timing diagram of a logging method based on the J2EE platform according to an embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and the detailed description.
As shown in fig. 1, a J2EE platform-based logging method includes:
s1, when the user logs in the web system through the browser, triggering the user associated plug-in to acquire the login information of the user, wherein the login information comprises: user name, IP address and login time;
and S2, when the user successfully logs in and accesses various service functions of the web system, triggering the user association plug-in to generate a corresponding log record and storing the log record in the database.
The log record includes: user name, IP address, start time of operation, end time of operation, service name, class name, method name, parameter information.
In step S2, the user association plug-in obtains a service name through the configured dictionary association according to the class name and the method name, where the association information is read from the configuration file or the database, and the service name includes the log type.
In step S2, the user association plug-in reads the association information from the configuration file by hot loading.
In step S1, the user association plug-in obtains the login information of the user through the login URL or obtains the login information of the user from the session according to the attribute name; and the user associated plug-in monitors a session failure method of the middleware, and triggers an action of deleting the login information of the user when the session failure is confirmed.
Before step S1, the method further includes:
and putting the user associated plug-in into CLASSPATH parameters of the middleware in the form of an independent jar file, modifying a start script of the middleware, adding a java agent parameter and configuring the proxy plug-in.
The database is a mysql database, and before the database is used, the configuration of the jdbc connection mysql database is completed.
The embodiment of the invention also provides a user associated plug-in, the user associated plug-in is obtained by dynamically modifying java byte codes based on java agent technology, the user associated plug-in is used for acquiring login information of a user when the user logs in a web system through a browser, and the login information comprises: user name, IP address and login time; and the system is also used for generating a corresponding log record and storing the log record in the database when the user accesses various service functions of the web system after logging in successfully.
The log record includes: user name, IP address, start time of operation, end time of operation, service name, class name, method name, parameter information.
The user association plug-in is specifically used for obtaining a service name through configured dictionary association according to the class name and the method name, wherein the association information is read from a configuration file or a database, and the service name comprises a log type.
The user association plug-in is specifically used for reading the association information from the configuration file in a hot loading mode.
The user association plug-in is specifically used for acquiring login information of a user through a login URL or acquiring the login information of the user from a session according to an attribute name; the user associated plug-in is also used for monitoring a session failure method of the middleware, and when the session failure is confirmed, an action of deleting the login information of the user is triggered.
Firstly, the user association plug-in mainly appears in the form of an independent jar file, and needs to be put into CLASSPATH parameters of the middleware, meanwhile, a start script of the middleware is modified, and a java parameter configuration proxy plug-in is added.
When a user logs in a WEB application through a browser, the user association plug-in acquires and stores user login information, and when the user accesses the WEB system to operate various service functions after logging in successfully, the association plug-in generates a log record and stores the log record in a database.
The user association plug-in is based on java agent technology and realizes acquisition by dynamically modifying java byte codes, such as: user name, IP address, start time of operation, end time of operation, service name, class name, method name, parameter information and the like.
In order to friendly show that the log belongs to the module, a service name field is added, the field is associated through a configured dictionary according to the class name and the method name, and the association mode can read a configuration file or read from a database.
The log storage is generally stored in a main database, and the log can also be stored in any data source through customized development.
The service name associated dictionary is not configured by default, configuration can be increased according to actual needs as required, and hot loading of the dictionary is supported without restarting middleware.
And configuring a data source stored by the log, wherein the default is that the data source is stored in the mysql database, and the configuration of the jdbc connection mysql database needs to be completed in advance.
And configuring an associated plug-in to acquire a login URL of user information or an attribute name in a session to acquire a currently logged-in user name.
As shown in fig. 2, the flow steps of a J2EE platform-based logging method include:
s101, a user initiates a function operation to a service Action;
s102, storing user information by the associated plug-in;
s103, the Service Action sends a request to the Service;
s104, the Service returns a result to the Service Action;
s105, generating an operation log by the associated plug-in;
s106, the operation log is stored in a database by the service Action;
s107, the database returns a result to the service Action;
and S108, the service Action returns a result to the user.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is intended to include such modifications and variations.
Claims (9)
1. A log recording method based on a J2EE platform is characterized by comprising the following steps:
s1, when the user logs in the web system through the browser, triggering the user associated plug-in to obtain the login information of the user, wherein the login information comprises: user name, IP address and login time;
s2, when the user successfully logs in and accesses various service functions of the web system, triggering the user associated plug-in to generate a corresponding log record and storing the log record in a database; the log records are: user name, IP address, start time of operation, end time of operation, service name, class name, method name and parameter information;
the user association plug-in is specifically used for obtaining a service name through configured dictionary association according to the class name and the method name, wherein the association information is read from a configuration file or a database, and the service name comprises a log type.
2. The J2EE platform-based logging method according to claim 1, wherein in step S2, the user association plug-in obtains the service name through configured dictionary association according to the class name and the method name, wherein the association information is read from a configuration file or the database by means of hot loading, and the service name includes a log type.
3. The J2EE platform-based logging method according to claim 1, wherein in step S1, the user association plug-in obtains the login information of the user via the login URL or obtains the login information of the user from the session according to the attribute name; the user associated plug-in monitors a session failure method of the middleware, and triggers an action of deleting the login information of the user when the session failure is confirmed.
4. The J2EE platform-based logging method according to any one of claims 1-3, further comprising, before step S1:
and putting the user associated plug-in into CLASSPATH parameters of the middleware in the form of an independent jar file, modifying a start script of the middleware, adding a java agent parameter, and configuring the proxy plug-in.
5. The J2EE platform-based logging method according to any one of claims 1-3, wherein the database is a mysql database, and the configuration of the jdbc-linked mysql database is completed before the database is used.
6. A user-associated plug-in for use in the method as claimed in any one of claims 1 to 5, wherein the user-associated plug-in is obtained by dynamically modifying java byte codes based on java agent technology, and the user-associated plug-in is used for obtaining login information of a user when the user logs in a web system through a browser, and the login information comprises: user name, IP address and login time; and the system is also used for generating a corresponding log record and storing the log record in the database when the user accesses various service functions of the web system after logging in successfully.
7. The user association plug-in of claim 6, wherein the log record comprises: user name, IP address, start time of operation, end time of operation, service name, class name, method name, parameter information.
8. The user association plug-in according to claim 7, wherein the user association plug-in is specifically configured to obtain the service name through configured dictionary association according to the class name and the method name, wherein the association information is read from a configuration file or the database in a hot loading manner, and the service name includes a log type.
9. The user association plug-in of claim 8, wherein the user association plug-in is specifically configured to obtain login information of a user through a login URL or obtain login information of the user from a session according to an attribute name; the user association plug-in is also used for monitoring a session failure method of the middleware, and when the session failure is confirmed, an action of deleting the login information of the user is triggered.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811215557.1A CN109542716B (en) | 2018-10-18 | 2018-10-18 | J2EE platform-based log recording method and user association plug-in |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811215557.1A CN109542716B (en) | 2018-10-18 | 2018-10-18 | J2EE platform-based log recording method and user association plug-in |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN109542716A CN109542716A (en) | 2019-03-29 |
| CN109542716B true CN109542716B (en) | 2022-04-08 |
Family
ID=65844226
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201811215557.1A Active CN109542716B (en) | 2018-10-18 | 2018-10-18 | J2EE platform-based log recording method and user association plug-in |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN109542716B (en) |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111309574B (en) * | 2020-02-17 | 2023-09-05 | 北京百度网讯科技有限公司 | Information processing method, device and equipment |
| CN111680010B (en) * | 2020-08-14 | 2020-12-22 | 北京东方通软件有限公司 | Design Method of Logging System for JavaEE Application Server |
| CN114253630B (en) * | 2021-12-23 | 2023-07-25 | 上海新炬网络信息技术股份有限公司 | Method for realizing log storage based on Java section modification Form change information |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101605056A (en) * | 2009-06-16 | 2009-12-16 | 中兴通讯股份有限公司 | A J2EE server monitoring device and monitoring method using the device |
| CN103647794A (en) * | 2013-12-31 | 2014-03-19 | 北京启明星辰信息安全技术有限公司 | Data correlation method based on J2EE platform and correlation plug-in |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7089565B2 (en) * | 2002-05-23 | 2006-08-08 | International Business Machines Corporation | Software architecture for providing a connection handle association |
-
2018
- 2018-10-18 CN CN201811215557.1A patent/CN109542716B/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101605056A (en) * | 2009-06-16 | 2009-12-16 | 中兴通讯股份有限公司 | A J2EE server monitoring device and monitoring method using the device |
| CN103647794A (en) * | 2013-12-31 | 2014-03-19 | 北京启明星辰信息安全技术有限公司 | Data correlation method based on J2EE platform and correlation plug-in |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109542716A (en) | 2019-03-29 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN109542716B (en) | J2EE platform-based log recording method and user association plug-in | |
| US20200151224A1 (en) | System and method for deep linking and search engine support for web sites integrating third party application and components | |
| CN111258722B (en) | Cluster log acquisition method, system, equipment and medium | |
| CN112231407B (en) | DDL synchronization method, device, equipment and medium of PostgreSQL database | |
| CN104102502B (en) | A kind of processing method that realizing heat deployment, device and server | |
| RU2017106890A (en) | METHOD FOR ACCESS TO WEB-UNITS, DEVICE AND WEB-UNIT SYSTEM | |
| CN104331369B (en) | Browser-based web page detection method and device, and server | |
| CN108959076A (en) | A kind of API on-line debugging method | |
| US8713368B2 (en) | Methods for testing OData services | |
| CN102752300B (en) | Dynamic antitheft link system and dynamic antitheft link method | |
| CN108846131A (en) | Weex page rendering method, apparatus, terminal and storage medium | |
| CN103095530B (en) | The monitoring of a kind of sensitive information based on preposition gateway and leakage prevention method and system | |
| CN101753971A (en) | Journal system and journal recording method in content management system in uniform video management platform | |
| US8880108B2 (en) | Short message processing method and apparatus | |
| CN111026637B (en) | Method and device for positioning problem code | |
| CN112612678A (en) | Zero-intrusion monitoring method and system based on byte code technology | |
| CN104901845A (en) | Automation test system and method of domain name WHOIS service | |
| CN105468511A (en) | Web page script error positioning method and apparatus | |
| CN108306918B (en) | A method for automatic acquisition of website access information based on program dynamic analysis | |
| CN114547697A (en) | Method, system and storage medium for obtaining user information for accessing SQL database | |
| CN103647795B (en) | The adjustment method that a kind of widget of realization remote service is called | |
| CN107770377A (en) | A kind of method of the establishment interactive voice mobile phone news client based on HTML5 | |
| CN108416035B (en) | Disconf-based unified management method for database mapping files | |
| CN106547670A (en) | The method and device of long-range reading and writing built-in Linux application program memory variable value | |
| CN114817294A (en) | Database access method and apparatus |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |