当前位置:网站首页>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
边栏推荐
- JS counts the number of times a string appears in another string
- February 3, 2022: a group of people (two or more) want to meet at the same place
- Reading redis source code (II) underlying data structure
- Daily shift series: memory problem of primary online service
- Detailed explanation of label smoothing and implementation of pytorch tenorflow
- Use micro build to realize search function
- January 31, 2022: Maze III. There is a ball in the maze of open spaces and walls. ball
- Optimization method of live weak network
- DAAS architecture and Implementation (I)
- Record a penetration caused by log4j
猜你喜欢

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

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

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

8. greed

6. template for integer and real number dichotomy

5. concept of ruler method

Vulnhub DC-5
随机推荐
Pre and post processing of pytest
Qingdao stadium has made headlines again, but it has nothing to do with sports
2022-01-28: for example, {5, 3, 1, 4} all number pairs are: (5,3), (5,1)
Xiamen's hidden gaopuge smart park has finally been uncovered
Batch generation of Codabar codes using Excel files
Calling applet demo modifying the default large screen view
Construction and exploration of vivo database and storage platform
Precision loss problem
Online signature with canvas
JS asynchronous mechanism
Line to line interviewer | one side of ByteDance
A penetration of an internal self built shooting range
Evolution of cloud firewall products
Optimization method of live weak network
How to set jewelry label paper
Reading redis source code (IV) command request processing flow
Simple implementation of promise basic method
Vs code remote SSH configuration
[data preparation and Feature Engineering] data cleaning
SAP mm initial transaction code MEK1 maintenance pb00 price