CN109962814A - A kind of the log capture and processing method of micro services Development Framework - Google Patents

A kind of the log capture and processing method of micro services Development Framework Download PDF

Info

Publication number
CN109962814A
CN109962814A CN201910249192.2A CN201910249192A CN109962814A CN 109962814 A CN109962814 A CN 109962814A CN 201910249192 A CN201910249192 A CN 201910249192A CN 109962814 A CN109962814 A CN 109962814A
Authority
CN
China
Prior art keywords
log
class
packet
information
section
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.)
Pending
Application number
CN201910249192.2A
Other languages
Chinese (zh)
Inventor
张晓玉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Inspur Cloud Information Technology Co Ltd
Original Assignee
Shandong Inspur Cloud Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shandong Inspur Cloud Information Technology Co Ltd filed Critical Shandong Inspur Cloud Information Technology Co Ltd
Priority to CN201910249192.2A priority Critical patent/CN109962814A/en
Publication of CN109962814A publication Critical patent/CN109962814A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/069Management of faults, events, alarms or notifications using logs of notifications; Post-processing of notifications
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Abstract

The present invention discloses the log capture and processing method of a kind of micro services Development Framework, it is related to backend application development technique field, build the back-end services engineering project of micro services Development Framework SpringBoot, creation starting class, log processing class and section class are created in public packet, packet path resolving is carried out in log processing class, carry out the recording process of operation log, it is called treatment process, carry out exception record process, it carries out return value treatment process and carries out log recording and transmission process, section class is scanned configuration to packet all in public packet by the point of contact expression formula of section, corresponding treatment process in processing class is called by notification method according to configuration, carry out the acquisition and processing of section log.

Description

A kind of the log capture and processing method of micro services Development Framework
Technical field
The present invention discloses the log capture and processing method of a kind of micro services Development Framework, is related to backend application development technique Field.
Background technique
With the development of internet technology, micro services become mainstream.Wherein SpringBoot is wherein outstanding person, SpringBoot micro services frame has light weight, efficient, expansible characteristic, can quickly develop, construct, being packaged application, exploitation It is efficient and convenient.Spring Boot management Spring container, third side plug simultaneously provide the service of many default system grades, only It needs a small amount of configuration and code that can complete, saves the plenty of time that project development expends in environment configurations.
In existing business development process, the processing to log is typically all to be added manually by developer.Developer Addition log manually is easy to ignore content and random print log, and can only be by controlling ability if necessary to visualize See log, operation log, and abnormal log inconvenience obtains in time and visualization.The life cycle costing of exploitation is high, later maintenance Also it causes high effort for very much.
The present invention provides the log capture and processing method of a kind of micro services Development Framework, based on Spring Boot this Micro services frame provides unified log capture, record, the method for saving and sending, and default automatically configures, and does not need exploit person Member's addition log code, reduces the life cycle costing of exploitation, later maintenance is also very very convenient.
Summary of the invention
The present invention is directed to problem of the prior art, provides the log capture and processing method of a kind of micro services Development Framework, The operation of log printing is avoided, log output more standardizes, and saves development time, recording and sending abnormal log, operation Log reduces O&M cost, the complexity of exploitation, improves exploitation and O&M efficiency.
Concrete scheme proposed by the present invention is:
A kind of the log capture and processing method of micro services Development Framework, build micro services Development Framework SpringBoot's Back-end services engineering project, creation starting class,
Log processing class and section class are created in public packet,
Packet path resolving is carried out in log processing class, is carried out the recording process of operation log, is called processed Journey carries out exception record process, carries out return value treatment process and carries out log recording and transmission process,
Section class is scanned configuration to packet all in public packet by the point of contact expression formula of section, is passed through according to configuration Notification method calls corresponding treatment process in processing class, carries out the acquisition and processing of section log.
Back-end services Maven engineering project, Maven engineering project handle are built using IDEA tool in the method The relevant dependence packet of SpringBoot is configured in pom.xml,
Or back-end services Gradle engineering project is built using IDEA tool, the relevant dependence of SpringBoot is configured To build.gradle,
Or other automation back-end services engineering projects are built using IDEA tool, the relevant dependence of SpringBoot It is configured in corresponding configuration file.
The method Zhong Bao path resolving goes out the packet path of program using JoinPoint analysis of object, according to packet Path parses layer where the module for calling engineering project and called process, and the module information and routing information parsed is simultaneously It returns.
The recording process of operation log obtains HttpServletRequest object in the method, by HttpServletRequest analysis of object goes out the IP information of url information, interface parameters information and calling and returns.
The class name information for the calling for calling treatment process parsing JoinPoint analysis of object to go out in the method, side Legitimate name information, the temporal information of relevant parameter information and calling and return.
Return value treatment process calls the proceed method of JoinPoint object to obtain the number returned in the method It is believed that ceasing and returning.
Log record process exports the different information contents the information of return according to the path of packet in the method.
Log transmission process is the information and exception record mistake returned in the recording process of operation log in the method The information that journey returns is sent to designated position.
Create three notification methods in the method the midsagittal plane class, respectively doBefore, doAround and DoAfterThrowing,
DoBefore method call handles the packet path resolving in class, carries out the recording process of operation log, carries out Call the acquisition and processing for the treatment of process and log recording section log related to transmission process progress;
DoAround method call handles return value treatment process and the related section day of log record process progress in class The acquisition and processing of will;
DoAfterThrowing method call handles the exception record process in class, and log record process and log are sent Process carries out the acquisition and processing of related section log.
Usefulness of the present invention is:
The present invention provides the log capture and processing method of a kind of micro services Development Framework, matches using towards section automation Set and the process of log processing, according to wrap it is different generate different logs, according to log different difference records and send, can be with The log of specific format is generated, sends and prints to console, or be recorded to database etc., and compared with prior art, by Log approach is sent in automatically configuring to record with system present invention employs system, developer reduces the generation of journalizing Code, operation maintenance personnel can receive exception information in time, save the exploitation O&M time, reduce the complexity of exploitation, improve O&M efficiency is developed, the information of output is more regular, and record log can be shown with web page, more intuitively.
Detailed description of the invention
Fig. 1 is the flow diagram that back-end services engineering project is created in the method for the present invention;
Fig. 2 is that the method for the present invention utilizes interface calling log processing flow chart.
Specific embodiment
The present invention provides the log capture and processing method of a kind of micro services Development Framework, builds micro services Development Framework The back-end services engineering project of SpringBoot, creation starting class,
Log processing class and section class are created in public packet,
Packet path resolving is carried out in log processing class, is carried out the recording process of operation log, is called processed Journey carries out exception record process, carries out return value treatment process and carries out log recording and transmission process,
Section class is scanned configuration to packet all in public packet by the point of contact expression formula of section, is passed through according to configuration Notification method calls corresponding treatment process in processing class, carries out the acquisition and processing of section log.
The present invention will be further explained below with reference to the attached drawings and specific examples, so that those skilled in the art can be with It more fully understands the present invention and can be practiced, but illustrated embodiment is not as a limitation of the invention.
By taking micro services Development Framework SpringBoot as an example, build SpringBoot back-end services project can be the present invention Common load dependent file is built, and the project of maven or gradle creation is also possible to, and SpringBoot dependence is matched It sets, creation starting class,
Process are as follows: by code Integrated Development Environment appliance id EA select creation Maven engineering or Gradle engineering or The engineering of other automation tools buildings is configured to the relevant dependence packet of SpringBoot if it is Maven engineering In pom.xml, the relevant dependence of SpringBoot is configured to build.gradle if it is Gradle engineering, is created in root Starting class is built, class, which introduces, explains@SpringBootApplication, creates main function, and engineering creation is completed, and can refer to figure Fig. 1;
Log processing class is created in public packet, includes (1) packet path resolving, (2) in creation class in log processing The recording process of operation log, the treatment process of (3) method call, (4) exception record process, (5) return value treatment process, (6) log record process, (7) log transmission process,
Wherein (1) packet path resolving parameter is JoinPoint object, goes out program by JoinPoint analysis of object Path is wrapped, layer where parsing the module and called method of calling according to packet path, the module information parsed, path letter Breath returns;(2) recording process of operation log obtains HttpServletRequest object, by HttpServletRequest pairs As parsing url, interface parameters, the information such as IP of calling, and return;(3) parameter of the treatment process of method call is JoinPoint object, parsing JoinPoint analysis of object go out call class name, method name, parameter, and call when Between and return;(4) exception record procedure parameter is JoinPoint object and Throwable object, parses Exception Type, different Normal information, and abnormal place row information and return;(5) parameter of return value treatment process is JoinPoint object, is called The proceed method of JoinPoint object obtains the data returned and return;(6) log record process parameter be above other The object that process returns exports different contents object above according to the path of packet, can be if it is Controller (2) content generated in, which is integrated into, to be come, and is not otherwise added, and can print console according to the log that certain format generates, or Person is saved in database;(7) log sending method parameter is the object returned in (2) (4), and operation log and exception are sent To message team, mail, the designated positions such as short message column or WebSocket;
Section class is created in public packet, is introduced note@Aspect and the@Component of section class, is created cutting for section The expression formula (execution) of point, point of contact is scanned configuration to all packets, three notification method difference of creation in the class of section For doBefore, doAround, doAfterThrowing ,@Before ,@Around ,@respectively are explained in method addition AfterThrowing,
The method parameter of doBefore is JoinPoint object, is called in log processing class (1) (2) (3) (6) (7) respectively Process;DoAround method parameter is JoinPoint object, calls (5) (6) process in log processing class; DoAfterThrowing method parameter is JoinPoint object and Throwable object, is called in log processing class (4) (6) (7) process, by section class by doBefore, the calling of tri- notification methods of doAround, doAfterThrowing is obtained Log and log is handled, process can refer to Fig. 2, can according to wrap it is different generate different logs, not according to log With difference record and send.
Embodiment described above is only to absolutely prove preferred embodiment that is of the invention and being lifted, protection model of the invention It encloses without being limited thereto.Those skilled in the art's made equivalent substitute or transformation on the basis of the present invention, in the present invention Protection scope within.Protection scope of the present invention is subject to claims.

Claims (9)

1. the log capture and processing method of a kind of micro services Development Framework, it is characterized in that building micro services Development Framework The back-end services engineering project of SpringBoot, creation starting class,
Log processing class and section class are created in public packet,
Packet path resolving is carried out in log processing class, is carried out the recording process of operation log, is called treatment process, into Row exception record process carries out return value treatment process and carries out log recording and transmission process,
Section class is scanned configuration to packet all in public packet by the point of contact expression formula of section, passes through notice according to configuration Method call handles corresponding treatment process in class, carries out the acquisition and processing of section log.
2. according to the method described in claim 1, it is characterized in that build back-end services Maven engineering project using IDEA tool, Maven engineering project is configured to SpringBoot relevant dependence packet in pom.xml
Or back-end services Gradle engineering project is built using IDEA tool, the relevant dependence of SpringBoot is configured to Build.gradle,
Or other automation back-end services engineering projects are built using IDEA tool, the relevant dependence of SpringBoot is configured Into corresponding configuration file.
3. according to the method described in claim 2, it is characterized in that packet path resolving goes out journey using JoinPoint analysis of object The packet path of sequence parses layer where calling the module and called process of engineering project, the mould parsed according to packet path Block message and routing information simultaneously return.
4. according to the method in claim 2 or 3, it is characterized in that the recording process of operation log obtains HttpServletRequest object goes out url information, interface parameters information and tune by HttpServletRequest analysis of object IP information simultaneously returns.
5. according to the method described in claim 4, it is characterized in that the tune for calling treatment process parsing JoinPoint analysis of object to go out Temporal information and the return of class name information, method name information, relevant parameter information and calling.
6. according to the method described in claim 5, it is characterized in that return value treatment process calls JoinPoint object Proceed method obtains the data information returned and return.
7. according to the method described in claim 6, it is characterized in that log record process the information of return according to the path of packet, it is defeated The different information content out.
8. according to the method described in claim 7, it is characterized in that log transmission process in the recording process of operation log returning Information and exception record process return information be sent to designated position.
9. -3, any method of 5-8 according to claim 1, it is characterized in that creating three notification methods in the class of section, respectively For doBefore, doAround and doAfterThrowing,
DoBefore method call handles the packet path resolving in class, carries out the recording process of operation log, is called The acquisition and processing for the treatment of process and log recording section log related to transmission process progress;
Return value treatment process and log record process in doAround method call processing class carry out related section log It obtains and handles;
DoAfterThrowing method call handles the exception record process in class, log record process and log transmission process Carry out the acquisition and processing of related section log.
CN201910249192.2A 2019-03-29 2019-03-29 A kind of the log capture and processing method of micro services Development Framework Pending CN109962814A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910249192.2A CN109962814A (en) 2019-03-29 2019-03-29 A kind of the log capture and processing method of micro services Development Framework

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910249192.2A CN109962814A (en) 2019-03-29 2019-03-29 A kind of the log capture and processing method of micro services Development Framework

Publications (1)

Publication Number Publication Date
CN109962814A true CN109962814A (en) 2019-07-02

Family

ID=67025274

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910249192.2A Pending CN109962814A (en) 2019-03-29 2019-03-29 A kind of the log capture and processing method of micro services Development Framework

Country Status (1)

Country Link
CN (1) CN109962814A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111130880A (en) * 2019-12-24 2020-05-08 杭州米络星科技(集团)有限公司 Micro-service system exception mechanism transfer method
CN112488080A (en) * 2020-12-23 2021-03-12 武汉烽火众智数字技术有限责任公司 Fault diagnosis and analysis method and system based on clustering algorithm

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105162884A (en) * 2015-09-25 2015-12-16 浪潮(北京)电子信息产业有限公司 Cloud management platform based on micro-service architecture
CN108595680A (en) * 2018-05-02 2018-09-28 四川长虹电器股份有限公司 The implementation method of the caching of XBRL
CN108647107A (en) * 2018-05-14 2018-10-12 浪潮软件集团有限公司 Unified exception handling method for micro-service development framework
CN112231379A (en) * 2020-10-16 2021-01-15 苏州浪潮智能科技有限公司 API (application program interface) auditing method, device, equipment and storage medium based on micro-service architecture

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105162884A (en) * 2015-09-25 2015-12-16 浪潮(北京)电子信息产业有限公司 Cloud management platform based on micro-service architecture
CN108595680A (en) * 2018-05-02 2018-09-28 四川长虹电器股份有限公司 The implementation method of the caching of XBRL
CN108647107A (en) * 2018-05-14 2018-10-12 浪潮软件集团有限公司 Unified exception handling method for micro-service development framework
CN112231379A (en) * 2020-10-16 2021-01-15 苏州浪潮智能科技有限公司 API (application program interface) auditing method, device, equipment and storage medium based on micro-service architecture

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
ELON.YANG: "SpringBoot切面应用-输出接口调用日志", 《HTTPS://BLOG.CSDN.NET/YLFOREVER/ARTICLE/DETAILS/83814879》 *
INKE: "Spring Boot 日志配置(超详细)", 《HTTPS://BLOG.CSDN.NET/INKE88/ARTICLE/DETAILS/75007649》 *
SIMEONE_XU: "SpringBoot记录Http请求日志的方法", 《HTTPS://WWW.JB51.NET/ARTICLE/158021.HTM》 *
无知者云: "用Gradle构建Spring Boot项目", 《HTTPS://WWW.CNBLOGS.COM/DAVENKIN/P/GRADLE-SPRING-BOOT.HTML?UTM_SOURCE=ITDADAO&UTM_MEDIUM=REFERRAL》 *
朱哲: "Springboot中Aspect实现切面(以记录日志为例)", 《CSDN博客HTTPS://BLOG.CSDN.NET/ZHUZHEZHUZHE1/ARTICLE/DETAILS/80565067》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111130880A (en) * 2019-12-24 2020-05-08 杭州米络星科技(集团)有限公司 Micro-service system exception mechanism transfer method
CN112488080A (en) * 2020-12-23 2021-03-12 武汉烽火众智数字技术有限责任公司 Fault diagnosis and analysis method and system based on clustering algorithm

Similar Documents

Publication Publication Date Title
AU2005202442B2 (en) System and method for auditing a network
CN101202668B (en) Network management system and network management method
CN110557437B (en) Universal mimicry distribution voting scheduling device and method based on user-defined protocol
CN101248680B (en) Rule based data collection and management in a wireless communications network
CN103546343B (en) The network traffics methods of exhibiting of network traffic analysis system and system
CN104636678B (en) The method and system of management and control is carried out under a kind of cloud computing environment to terminal device
CA2657487A1 (en) Distributed capture and aggregation of dynamic application usage information
CN109962814A (en) A kind of the log capture and processing method of micro services Development Framework
CN101662484A (en) Method for uploading file of RFC1867 specification based HTTP protocol
RU2636112C1 (en) Object of interface management service, function service object and method of control of elements
CN102271052A (en) Network system, network management device and gateway device
CN108717362A (en) It is a kind of based on can be after the network equipments configuration model and configuration method of bearing structure
CN101989919A (en) Local software diagnosing and maintaining system as well as corresponding method and system for diagnosis and maintenance
CN108449235A (en) Equipment alarm calculation processing system and processing method
CN105701009B (en) Security application test method in mobile terminal
CN113658591A (en) Voice interaction adaptation system for smart home
CN114254606A (en) Microservice framework model
CN103384246B (en) Safety supervision system login assistant method
CN101499031A (en) Software bug feedback system and method
US8725901B2 (en) Analysis tool for intra-node application messaging
US20060200548A1 (en) Automation engine and method for providing an abstraction layer
JP2009265718A (en) Network device transmitting only difference data of network management information, server, program and method
EP1856605B1 (en) Systems and methods for remote cross-platform instructions
Masood et al. An automated approach to regression testing of web services based on WSDL operation changes
JP2006190033A (en) Information processing system and processing method for communication reproduction

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190702