Vote count:
0
My objective is to have every "internal" Spring log message coming from Springboot sent to my log4j log file. This includes the embedded tomcat server logging.
I have successfully setup log4j to the point that I can log to the console and a file using a log4j logger object.
I have excluded commons-logging from my classpath and added the slf4j libs per this guide (with the intention of making log4j the default logger for Spring): http://ift.tt/1DjyTUn
The problem is that none of the "internal" Spring log messages are being sent to my log4j file. They only go to the console, and they still have their own format, not the format I specify for the console.
Is it possible to make log4j Spring's default loggers so that all Spring logging obeys the log4j.properties? Am I missing something?
Here are my logging properties for reference:
log4j.rootLogger=DEBUG, stdout, file
#Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p 0000 --- [%t] %c{1}:%L - %m%n
log4j.category.org.springframework.beans.factory=DEBUG
#Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\\logs\\electrarecon.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=100
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
How direct all internal Springboot logging to log4j?
Aucun commentaire:
Enregistrer un commentaire