当前位置:网站首页>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
边栏推荐
- PHP code specification
- JS how to delete an item specified in an array
- Related concepts of TTF, TOF, woff and woff2
- CFS After the CHM file is opened, the hyperlink content cannot be loaded and blank is displayed
- How does native JS get the child elements of the parent element that the current element belongs to
- How to use fortress on mobile devices
- Some people are crazy, others are running away, and open source software is both hot and cold
- Summary of website navigation design and website link optimization
- Understand one article: build an activity analysis system
- Tencent cloud server CVM system tool configuration
猜你喜欢

Vulnhub DC-5

5. concept of ruler method

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

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

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

8. greed

6. template for integer and real number dichotomy
随机推荐
Goframe framework (RK boot): fast implementation of server-side JWT verification
What if the software gets stuck and cannot end the process?
Account protection and use scheme
How to batch generate ean14 barcode through TXT file
The difference between code39 and code93
No error is reported when using the Gorm framework to create a table, but the data cannot be inserted successfully
JS to realize character case switching
Zoom/skype/ nailing / live broadcast / conference / online video real-time subtitle generation and translation, simultaneous interpretation
Construction and exploration of vivo database and storage platform
Scanning technology (getting started with web security 06)
Capture passwords of all chrome versions
Reading redis source code (V) master-slave replication and sentinel mechanism
Exploration on the framework of stream batch integration technology and its practice in kangaroo cloud number stack
PHP code specification
PowerShell automated reinstallation of cloudbase init to version 1.1.2
QUIC or TCP
2D visual empowerment smart water green intensive development
5 trends brought to us by customers
2022-01-25: serialize and deserialize n-ary tree. Serialization means that a
Simple implementation of promise basic method