Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure Logback and how to improve TPS

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

In view of how to configure Logback and how to improve TPS, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

Springboot project comes with Logback and slf4j dependencies, so you can use log printing Logback framework to load logback or logback-spring configuration files under resource by default without introducing dependencies. The following configuration file says that the log of the project output is output to the hard disk in a file format.

SpringBootDemo ${LOG_PATH} / ${APPDIR} / log_error.log ${LOG_PATH} / ${APPDIR} / error/log-error-%d {yyyy-MM-dd}.% i.log 50MB true ${FILE_LOG_PATTERN} utf-8 error ACCEPT DENY ${LOG_PATH} / ${APPDIR} / log_warn.log ${LOG_PATH} / ${APPDIR} / warn/log-warn-%d {yyyy-MM-dd}.% i.log 50MB true ${FILE_LOG_PATTERN} utf-8 Warn ACCEPT DENY ${LOG_PATH} / ${APPDIR} / log_info.log ${LOG_PATH} / ${APPDIR} / info/log-info-%d {yyyy-MM-dd}.% i.log 50MB true ${FILE_LOG_PATTERN} Utf-8 info ACCEPT DENY ${LOG_PATH} / ${APPDIR} / log_debug.log ${LOG_PATH} / ${APPDIR} / debug/log-debug-%d {yyyy-MM-dd}.% i.log 50MB true ${ FILE_LOG_PATTERN} utf-8 debug ACCEPT DENY 0 256 0 256 ${CONSOLE_LOG_PATTERN} utf-8 info `

Tag, required, used to specify the most basic log level. Above, specify four log level tags: debug, info, warn, error, and add append tag name: for different log levels, including debug, info, warn, error level, class: log output policy, generally divided into console output and file output, ConsoleAppender is console output RollingFileAppender specifies the filter policy label for the file output label, the filter type label, the log output format label, the collection policy, such as rebuilding the log file tag based on time or after the file reaches a certain size to specify the log storage address. Through this configuration, the goal of classifying and collecting logs on a daily basis has been achieved.

Logback advanced features the configuration of logs before asynchronously outputting logs is based on synchronization, and each time the logs are output to a file, a disk IO is performed. Using the way of asynchronous log writing without disk IO, blocking threads and causing unnecessary performance loss. The way to output the log asynchronously is simple. Add an appender based on asynchronous write log and point to the previously configured appender.

0256 0256 * * Asynchronous output Log performance Test * * since it can improve performance, a test comparison must be carried out. How many times can synchronous and asynchronous output log performance be improved? Server hardware CPU Quad Core memory 8G Test tool Apache Jmeter

Asynchronous output log

Number of threads: 100

Ramp-Up Loop (which can be understood as the time it takes to start a thread): 0 can be understood as 100 threads enabled at the same time

Synchronous output log

Number of threads: 100

Ramp-Up Loop (which can be understood as the time it takes to start a thread): 0 can be understood as 100 threads enabled at the same time

After the test is completed, the TPS has been increased by more than 3 times. The answers to the questions about how to configure Logback and how to improve TPS are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report