当前位置:网站首页>Logging log configuration of vertx
Logging log configuration of vertx
2022-07-03 07:25:00 【Sleeping Empire】
Introduce
Vertx Support the use of its internal customized logging method , It also supports user-defined logging
- Configuration through environment variables vertx.logger-delegate-factory-class-name
- If classpath There are vertx-default-jul-logging.properties file , The default is jdk journal
- stay classpath Use if there are the following dependencies , The order is as follows :
- SLF4J
- Log4J
- Log4J2
1. maven Project dependence
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.4</version>
</dependency>
2.log4j2.xml The configuration is as follows
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Properties>
<property name="CONSOLE_LOG_PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight{%5p}{TRACE=blue, DEBUG=green, INFO=green,
WARN=yellow, ERROR=red, FATAL=red} %tid --- [%style{%15.15t}{magenta}] %-40.40logger{39}---[%4L] : %m%n"/>
<property name="FILE_LOG_PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p %tid --- [%15.15t] %-40.40logger{39}---[%4L] : %m%n"/>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="${CONSOLE_LOG_PATTERN}"/>
</Console>
<RollingRandomAccessFile name="FILE" fileName="logs/logging-log4j2.log" append="true"
filePattern="logs/logging-log4j2.log.%d{yyyyMMdd}">
<PatternLayout>
<Pattern>${FILE_LOG_PATTERN}</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="24" modulate="true"/>
</Policies>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<AsyncLogger name="com.lance.logging" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="Console"/>
<appender-ref ref="FILE"/>
</AsyncLogger>
<Root level="debug">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
3. The log is printed as follows
@Slf4j
public class MainVerticle extends AbstractVerticle {
@Override
public void start(Promise<Void> startPromise) throws Exception {
vertx.createHttpServer().requestHandler(req -> {
IntStream.range(0, 100).forEach(i -> log.info("===>start print i: {}, time: {}", i, System.nanoTime()));
req.response().putHeader("content-type", "text/plain").end("Hello from Vert.x!");
}
).listen(8888, http -> {
if (http.succeeded()) {
startPromise.complete();
log.info("HTTP server started on port 8888");
} else {
startPromise.fail(http.cause());
}
});
}
}
4. Full address of the project
边栏推荐
- Dora (discover offer request recognition) process of obtaining IP address
- The underlying mechanism of advertising on websites
- New stills of Lord of the rings: the ring of strength: the caster of the ring of strength appears
- Download address collection of various versions of devaexpress
- Advanced API (UDP connection & map set & collection set)
- Some basic operations of reflection
- PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
- [Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
- 《指环王:力量之戒》新剧照 力量之戒铸造者亮相
- MySQL syntax (basic)
猜你喜欢
【已解决】Unknown error 1146
你开发数据API最快多长时间?我1分钟就足够了
[set theory] partition (partition | partition example | partition and equivalence relationship)
深度学习参数初始化(一)Xavier初始化 含代码
TCP cumulative acknowledgement and window value update
Topic | synchronous asynchronous
【开发笔记】基于机智云4G转接板GC211的设备上云APP控制
Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS
3311. Longest arithmetic
Summary of abnormal mechanism of interview
随机推荐
【已解决】SQLException: Invalid value for getInt() - ‘田鹏‘
Common architectures of IO streams
【已解决】win10找不到本地组策略编辑器解决方法
Understanding of class
VMware virtual machine installation
7.2刷题两个
TCP cumulative acknowledgement and window value update
带你全流程,全方位的了解属于测试的软件事故
Circuit, packet and message exchange
Selenium key knowledge explanation
Map interface and method
Sorting, dichotomy
“百度杯”CTF比赛 2017 二月场,Web:爆破-1
Common analysis with criteria method
Margin left: -100% understanding in the Grail layout
Use of framework
The underlying mechanism of advertising on websites
你开发数据API最快多长时间?我1分钟就足够了
【CMake】CMake链接SQLite库
10 000 volumes - Guide de l'investisseur en valeur [l'éducation d'un investisseur en valeur]