In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to actively add logs in Spring Sleuth, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Spring Sleuth is added to active logs through the logging.pattern.level variable.
Add to TraceEnvironmentPostProcessor
@ Override public void postProcessEnvironment (ConfigurableEnvironment environment, SpringApplication application) {Map map = new HashMap (); / / This doesn't work with all logging systems but it's a useful default so you see / / traces in logs without having to configure it. / / if sleuth is enabled here, modify the value of logging.pattern.level if (Boolean.parseBoolean (environment.getProperty ("spring.sleuth.enabled", "true")) {map.put ("logging.pattern.level", "% 5p [${spring.zipkin.service.name:$ {spring.application.name:-}})" % X {XmurB3Mutual TraceIdVR -},% X {XMULB3Mutual SpanIdPartition -},% X {XMube SpanMel ExportRose -}] ") } / / TODO: Remove this in 2.0.x. For compatibility we always set to true if (! environment.containsProperty (SPRING_AOP_PROXY_TARGET_CLASS)) {map.put (SPRING_AOP_PROXY_TARGET_CLASS, "true");} addOrReplace (environment.getPropertySources (), map);}
Set the value of LOG_LEVEL_PATTERN to the value of logging.pattern.level in LoggingSystemProperties
Public void apply (LogFile logFile) {RelaxedPropertyResolver propertyResolver = RelaxedPropertyResolver. This.environment, "logging."); setSystemProperty (propertyResolver, EXCEPTION_CONVERSION_WORD, "exception-conversion-word"); setSystemProperty (PID_KEY, new ApplicationPid (). ToString ()) SetSystemProperty (propertyResolver, CONSOLE_LOG_PATTERN, "pattern.console"); setSystemProperty (propertyResolver, FILE_LOG_PATTERN, "pattern.file"); / / LOG_LEVEL_PATTERN = "LOG_LEVEL_PATTERN" set to the environment variable setSystemProperty (propertyResolver, LOG_LEVEL_PATTERN, "pattern.level") If (logFile! = null) {logFile.applyToSystemProperties ();}} Settings
Parsing in PropertyAction#begin configures parsing the current string in InterpretationContext
Public String subst (String value) {if (value = = null) {return null;} return OptionHelper.substVars (value, this, context);} public static String substVars (String input, PropertyContainer pc0, PropertyContainer pc1) {try {return NodeToStringTransformer.substituteVariable (input, pc0, pc1) } catch (ScanException e) {throw new IllegalArgumentException ("Failed to parse input [" + input + "]", e);} public static String substituteVariable (String input, PropertyContainer pc0, PropertyContainer pc1) throws ScanException {Node node = tokenizeAndParseString (input); NodeToStringTransformer nodeToStringTransformer = new NodeToStringTransformer (node, pc0, pc1); return nodeToStringTransformer.transform ();} public String transform () throws ScanException {StringBuilder stringBuilder = new StringBuilder () CompileNode (node, stringBuilder, new Stack ()); return stringBuilder.toString ();} private void compileNode (Node inputNode, StringBuilder stringBuilder, Stack cycleCheckStack) throws ScanException {Node n = inputNode; while (n! = null) {switch (n.type) {case LITERAL: handleLiteral (n, stringBuilder); break Case VARIABLE: handleVariable (n, stringBuilder, cycleCheckStack); break;} n = nnextt;}} private void handleVariable (Node n, StringBuilder stringBuilder, Stack cycleCheckStack) throws ScanException {/ /. String key = keyBuffer.toString (); String value = lookupKey (key); / /...} private String lookupKey (String key) {String value = propertyContainer0.getProperty (key); if (value! = null) return value; if (propertyContainer1! = null) {value = propertyContainer1.getProperty (key) If (value! = null) return value;} / / find the value value = OptionHelper.getSystemProperty (key, null) here; if (value! = null) return value; value = OptionHelper.getEnv (key); if (value! = null) {return value;} return null } public static String getSystemProperty (String key, String def) {try {return System.getProperty (key, def);} catch (SecurityException e) {return def;}} about how to actively add logs to Spring Sleuth is shared here. I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.