问题
I have developed spring batch multifile processor. Now requirement is to write all program specific logs like for example:
logger.info(" this is reader reading employee record:" employee.toString);
logger.info(" this is processor processing employee record:" employee.toString);
to the file. Tried to solve by using logback.xml.
<appender name="file1" class="ch.qos.logback.core.FileAppender">
<file>${LOG_PATH}/log.log</file>
<encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%msg%</Pattern>
</encoder>
</appender>
then started disabling all other logs of spring, hibernate etc...
<logger name="org.springframework" level="OFF">
<appender-ref ref="file1" />
</logger>
did the same for org.hibernate. but looking like i have to disable lot like tomcat and org.apache etc...
any suggestion to send only program logs which were written in methods to the log file.
As this is spring batch any way it can be simplified ?
回答1:
As i did not get any easy way, this is what i did.
Added all logs to list. returned same in processor. in writer written those logs to file.
来源:https://stackoverflow.com/questions/57015378/how-to-write-only-program-specific-logs-to-file-in-spring-batch-with-spring-boot