I have a lambda function that reads file from S3 bucket and stores it to another S3 bucket. The lambda is working fine, but when I see the cloudwatch for logs, I see additional logs which is not needed.
The additional logs that I get are like below.,
[main] DEBUG org.springframework.context.annotation.AnnotationConfigApplicationContext
[main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory
[main] DEBUG com.amazonaws.AmazonWebServiceClient
[main] DEBUG org.apache.http.headers
[main] DEBUG org.apache.http.wire
I want to display only the logger.info()
used inside the code to be displayed in cloudwatch. Is there any way to restrict those logs from getting displayed ? Can someone provide an example code for reference ?
I am setting log4j.properties file, with the below content.
log4j.rootLogger=INFO
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
# Log all HTTP content (headers, parameters, content, etc) for
# all requests and responses. Use caution with this since it can
# be very expensive to log such verbose data!
log4j.logger.org.apache.http.wire=INFO
This is a Log4J 1.x logging configuration, so the way to eliminate unwanted messages is:
Change the root logger to only allow important messages (you could set it to OFF
, but you really want to see errors wherever they occur):
log4j.rootLogger=ERROR
Change the logger for your application to enable logging:
log4j.logger.com.example.myprogram=INFO
If you have multiple packages that you want to display, you need to set their logging configuration individually.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.