Async log

This commit is contained in:
hongqiaowei
2021-10-11 09:36:27 +08:00
parent 38c994007e
commit c7650fa774
2 changed files with 8 additions and 4 deletions

View File

@@ -182,9 +182,12 @@ import we.log.LogSendAppender;
) )
@EnableDiscoveryClient @EnableDiscoveryClient
public class FizzBootstrapApplication { public class FizzBootstrapApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(FizzBootstrapApplication.class); private static final Logger LOGGER = LoggerFactory.getLogger(FizzBootstrapApplication.class);
public static void main(String[] args) { public static void main(String[] args) {
System.setProperty("log4j2.contextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
SpringApplication springApplication = new SpringApplication(FizzBootstrapApplication.class); SpringApplication springApplication = new SpringApplication(FizzBootstrapApplication.class);
springApplication.setApplicationContextClass(CustomReactiveWebServerApplicationContext.class); springApplication.setApplicationContextClass(CustomReactiveWebServerApplicationContext.class);
FizzAppContext.appContext = springApplication.run(args); FizzAppContext.appContext = springApplication.run(args);

View File

@@ -6,19 +6,20 @@
</properties> </properties>
<Appenders> <Appenders>
<Console name="Console" target="SYSTEM_OUT"> <Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level [%-29t] %c{1}.%M:%L %m %ex%n"/> <!--<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level [%-29t] %30c{1}.%41M:%4L %m %ex%n"/>-->
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %30c{1}.%41M:%4L %m %ex%n"/>
</Console> </Console>
<LogSend name="LogSend"> <LogSend name="LogSend">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %level %logger{36} - %msg%n"/> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %level %logger{36} - %msg%n"/>
</LogSend> </LogSend>
</Appenders> </Appenders>
<Loggers> <Loggers>
<Root level="warn"> <Root level="warn" includeLocation="true">
<AppenderRef ref="Console"/> <AppenderRef ref="Console"/>
<AppenderRef ref="LogSend"/> <AppenderRef ref="LogSend"/>
</Root> </Root>
<!-- suppress the warn 'No URLs will be polled as dynamic configuration sources.' --> <!-- suppress the warn 'No URLs will be polled as dynamic configuration sources.' -->
<logger name="com.netflix.config.sources.URLConfigurationSource" level="ERROR"/> <logger name="com.netflix.config.sources.URLConfigurationSource" level="ERROR" includeLocation="true"/>
<Logger name="we" level="info"/> <Logger name="we" level="info" includeLocation="true"/>
</Loggers> </Loggers>
</Configuration> </Configuration>