Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling Spring log, to have readable logs

Tags:

How can I disable Spring logs to have log outputs that I can easily read or someone else can read. An answer to a similar question at, how to disable spring bean loading log suggested to comment out all lines having org.springframework substring in log4j.properties file. In my case there no such lines.

Here is log4j.properties

# Define the root logger with appender file
log4j.rootLogger = DEBUG, stdout

# Define the file appender
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# Set the name of the logs destination
log4j.appender.stdout.target=System.out

# Set the immediate flush to true (default)
log4j.appender.stdout.ImmediateFlush=true

# Set the threshold to debug mode
log4j.appender.stdout.Threshold=debug

# Set the append to false, overwrite
log4j.appender.stdout.Append=false

# Define the layout for appender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.conversionPattern=%d{yyyy-MM-dd}:%m%n 
like image 594
LeandreM Avatar asked Sep 06 '13 00:09

LeandreM


People also ask

How do I turn off Info logs in SLF4J?

To disable this behavior, you must add a logback configuration file called logback. xml in your java classpath root. You can download this minimal logback. xml file and add it in the src/main/resources directory for a maven project or beside fr directory for a simple java project.

How do I disable debug in spring boot?

In your case you must set logging. level. root on one of level from INFO, WARN, ERROR,FATAL or OFF to turn off all logging.


1 Answers

Your default logging, for everything that isn't explictily specified, is DEBUG. So everything is logged at that level (judging from your configuration), basically you are flooding your logs. You should not remove loggers for org.springframework you should add them and set another level for them.

log4j.logger.org.springframework=INFO 

or whatever log level level you like.

like image 158
M. Deinum Avatar answered Oct 14 '22 23:10

M. Deinum