I recommended him some distributed tracking frameworks ,skywalking,pinpoint. He read it and said , Perfect , But it's a bit expensive to build and implement . It's also about storage costs , The company's log service has been purchased by a third party . It's a bit of a hassle to connect . I'm afraid they don't agree with such a toss .
Nearly period of time , See such an open source framework in the open source community , Known as a lightweight log tracking artifact ,10 Minutes to connect , So I recommended it to my friends . After a few days , He told me that it was very appropriate for his pain point now , Now it's in production , The preliminary effect is that , Still very satisfied . It can position their logs and reduce the time cost .
Invited , So I'm going to analyze this framework . Give you an intuitive understanding .
This framework is called TLog, The project is hosted in Gitee On
gitee.com/dromara/TLo…
The main page looks like this , It's a thick dark system ...
I use it , To put it bluntly , Namely TLog Prefixes each line automatically , It's called a label . Tags are divided into system level tags and business type tags , Business label developers can customize . Draw a picture to make it easy to understand :
TLog Each line of log that is finally rendered , It's like the picture above . The system log , The information that can be displayed at present is 5 individual , Upstream information can let you know who called your system , link TraceId It is the only global link across microservices ID, Search for a Id, You can get the log of the same request in all systems . This one is still very fragrant !
About SpanId, The explanation on the official website is , This represents the position of this call in the whole call link tree , The specific demonstration borrows the picture of the official website , The explanation is quite clear :
Individual to SpanId The understanding is , This thing lets you know the hierarchy of the system in a call chain , If it's collected , Can pass spanId Generate a call link tree . I really hope TLog Can realize the display of this tree , Unfortunately, we still don't support .
“TLog The positioning of is to provide the simplest way to solve the problem of log tracking , It doesn't collect logs , There's no need for additional storage space , It just automatically tags your business log , Automatic generation TraceId A whole link through your microservice . And provide upstream and downstream node information . Suitable for small and medium-sized enterprises and companies that want to quickly solve the problem of log tracking .“
This is a repeat of the official website , In fact, when I was testing ,TLog The log provided is the log itself , In multi node micro Services , The logs are still scattered . It's just logically concatenated with the log to a certain extent . But at the same time ,TLog The document also suggests that , Use other schemes to do log collection . such as ELK, Alicloud log , Other paid log products and so on .TLog Just modifying the log , No new logs are generated . So docking with other log collection schemes , There is no problem at all , For companies that have linked log collection solutions , There's no need to change anything .
Every company uses a variety of log frameworks .TLog Claims to support the three main logging frameworks :log4j,log4j2,logback
In practice , Here 3 In a frame ,TLog They can also print out labels normally . Just in the process of access , The official access methods are 3 Kind of
Test it out ,javaagent It's not stable for some projects , Some complex projects will be ineffective . For the most stable log adaptation method , Tested the company's projects , It's really connected .
Access mode , Follow the documentation step by step .
Since it's log tracking across microservices , In terms of implementation, we should also focus on the common RPC Be supported .TLog Support Dubbo,SpringCloud,Dubbox Three commonly used RPC, That's a good point .
In practice , stay Spring cloud This piece of ,TLog Also supports the SpringCloud Of Gateway.
During the access process , Whatever it is RPC frame , stay springboot In the environment TLog It can also adapt automatically , You can assemble it automatically by introducing one . No additional configuration required . That's handy .
But in the native spring In the environment ( Not springboot), Still need xml The extra configuration of , But it's also relatively simple , The document also has special instructions .
In addition to the labels given by the system , I find TLog Another feature is allowing developers to customize tags . Access is also very simple , for instance :
Just add a label to the method , So all the logs under this method , Including the following N A hierarchy , Will automatically add the label you defined
This function is in the layout and search of logs , You can add a lot of markers . This is great !
Even custom tags support logical processing of information , You can customize the class to handle this information
This specific effect , You can try . All in all, one tag can handle all custom tags .
Parameters & Time consuming printing support :
Do everything with your heart , Pay great attention to details . It looks insignificant 、 If the tedious work is done thoroughly, it will have unexpected value .
Of course, to become a technical bull, you also need a certain ideological pattern , Thought determines which direction you want to go in the future , I suggest reading more books on life planning , Learn more about the ideological pattern of celebrities , In the future, you will go further .
I've done a collation of more technical point mind maps , It covers the most popular Internet at present 99% Technical points , Here I share this map , And a set of interview system for golden nine and silver ten , Up to collection , Down to distributed microservices
How to obtain this set of high-quality information ?
Java Interview selection questions 、 Structure the actual document delivery gate : Get it free of charge here