当前位置:网站首页>Uploading logs using loghub log4j appender
Uploading logs using loghub log4j appender
2022-06-23 03:09:00 【No comment】
Look at the effect :
One 、 Project introduction and configuration
1、Maven To configure
<dependency>
<groupId>com.tencentcloudapi.cls</groupId>
<artifactId>tencentcloud-cls-log4j-appender</artifactId>
<version>1.0.2</version>
</dependency>2、log4j.properties To configure
log4j.rootLogger=DEBUG,loghubAppender #loghubAppender log4j.appender.loghubAppender=com.tencentcloudapi.cls.LoghubAppender # Logging service http Address , Required parameters log4j.appender.loghubAppender.endpoint=ap-chengdu.cls.tencentcs.com # User identity , Required parameters log4j.appender.loghubAppender.accessKeyId= Own SecretId log4j.appender.loghubAppender.accessKeySecret= Own SecretKey # Set up log The format of the field , Required parameters log4j.appender.loghubAppender.layout=org.apache.log4j.PatternLayout log4j.appender.loghubAppender.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n # Specify the log subject , Optional parameters log4j.appender.loghubAppender.topicID = My own theme ID # Specify the log source , Optional parameters log4j.appender.loghubAppender.source = # Single producer The maximum log size that an instance can cache , The default is 100MB. log4j.appender.loghubAppender.totalSizeInBytes=104857600 # If producer Insufficient free space , The caller is send Maximum blocking time on method , The default is 60 second . In order not to block the thread that prints the log , It is strongly recommended that this value be set to 0. log4j.appender.loghubAppender.maxBlockMs=0 # The size of the thread pool that executes the log sending task , The default is the number of available processors . log4j.appender.loghubAppender.sendThreadCount=8 # When one ProducerBatch The log size cached in is greater than or equal to batchSizeThresholdInBytes when , The batch Will be sent , The default is 512 KB, The maximum can be set to 5MB. log4j.appender.loghubAppender.batchSizeThresholdInBytes=524288 # When one ProducerBatch The number of cached log entries in is greater than or equal to batchCountThreshold when , The batch Will be sent , The default is 4096, The maximum can be set to 40960. log4j.appender.loghubAppender.batchCountThreshold=4096 # One ProducerBatch Stay time from creation to sendable , The default is 2 second , The minimum can be set to 100 millisecond . log4j.appender.loghubAppender.lingerMs=2000 # If a ProducerBatch First send failed , The number of times it can be retried , The default is 10 Time . # If retries Less than or equal to 0, The ProducerBatch After the first sending failure, it will directly enter the failure queue . log4j.appender.loghubAppender.retries=10 # The larger the parameter, the more information you can trace , But it also consumes more memory . log4j.appender.loghubAppender.maxReservedAttempts=11 # The backoff time of the first retry , The default is 100 millisecond . #Producer Sampling exponential backoff algorithm , The first N The scheduled wait time for retries is baseRetryBackoffMs * 2^(N-1). log4j.appender.loghubAppender.baseRetryBackoffMs=100 # Maximum backoff time for retry , The default is 50 second . log4j.appender.loghubAppender.maxRetryBackoffMs=50000 # Set time format , Optional parameters log4j.appender.loghubAppender.timeFormat=yyyy-MM-dd'T'HH:mm:ssZ # Set the time zone to East 8 , Optional parameters log4j.appender.loghubAppender.timeZone=Asia/Shanghai # Output INFO Level and above log4j.appender.loghubAppender.Threshold=DEBUG
Two 、 Create a new test class and run
import org.apache.log4j.Logger;
class Test_Loghub_log4j_Appende {
private static final org.apache.log4j.Logger Logger= org.apache.log4j.Logger.getLogger(org.apache.log4j.Logger.class);
public static void main(String[] args) {
Logger.info(" test ");
}
}3、 ... and 、CLS Console configuration index
Four 、JDK Environmental Science
边栏推荐
- 1 approved, edit again
- What if the software gets stuck and cannot end the process?
- Reading redis source code (V) master-slave replication and sentinel mechanism
- Optimization method of live weak network
- Function recursion and iteration
- Zoom/skype/ nailing / live broadcast / conference / online video real-time subtitle generation and translation, simultaneous interpretation
- Implementing StdevP function of Excel with PHP
- February 1, 2022: painting house II. If there is a row of houses, N in total, each
- Initial xxE
- Operating wechat cache by using wechat low code
猜你喜欢

Soft exam information system project manager_ Information system comprehensive testing and management - Senior Information System Project Manager of soft test 027

8. greed

How to store, manage and view family photos in an orderly manner?

5. concept of ruler method

6. template for integer and real number dichotomy

Soft exam information system project manager_ Contract Law_ Copyright_ Implementation Regulations - Senior Information System Project Manager of soft exam 030

Vulnhub DC-5
随机推荐
Concept and function of ES6 symbol
CVE-2021-21973 Vmware Vcenter SSRF POC
MIT 6. S081/fall 2020 build risc-v and xv6 development and debugging environment
How does easyplayer embed a video snapshot into a demo?
Flowable refactoring process editor to obtain user information
Learning record -- memo on constructors and attributes in C
How to gracefully solve the problem of platform font adaptation
February 4, 2022: combined total IV. Give you a number composed of different integers
JS event bubble and event capture
Reading redis source code (VI) multi threading of redis 6.0
Why not use math random() ?!
Calling applet demo modifying the default large screen view
Application of map function in JS
Im web demo invite end hang up error avoidance
The difference between code39 and code93
How audio and video technology provides a completely true and stable new experience for the meta universe
February 1, 2022: painting house II. If there is a row of houses, N in total, each
JS to determine whether the page is opened for the first time today
CFS topics
Reinforcement learning series (IV) -policygradient example