我已经在Spring Boot应用程序中使用log4j2配置了日志记录。它显示的是springboot启动日志记录,当我到达终点时,控制器内部的日志记录未附加到日志文件中。但是,当我停止应用程序时,内部控制器的日志记录将附加到日志文件中。
我尝试在log4j配置文件中使用不同的日志级别,但是没有运气。
下面是我的log4j2配置文件。
<Configuration status="DEBUG" monitorInterval="30">
<Properties>
<Property name="LOG_PATTERN">
%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${hostName} --- [%15.15t] %-40.40c{1.} : %m%n%ex
</Property>
</Properties>
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT" follow="true">
<PatternLayout pattern="${LOG_PATTERN}"/>
</Console>
<!-- Rolling File Appender -->
<RollingFile name="FileAppender" fileName="C:\Users\vkode200\logs\BulkSolveService.log"
filePattern="C:\Users\vkode200\logs\BulkSolveService-demo-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<Pattern>${LOG_PATTERN}</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="com.Test.BulkSolve" level="info" additivity="false">
<AppenderRef ref="FileAppender" />
<!-- <AppenderRef ref="ConsoleAppender" /> -->
</Logger>
<Logger name="com.Test.BulkSolve.Controller" level="info" >
<AppenderRef ref="FileAppender" />
<!-- <AppenderRef ref="ConsoleAppender" /> -->
</Logger>
<Logger name="com.Test.BulkSolve.Dao.*" level="info" >
<AppenderRef ref="FileAppender" />
<!-- <AppenderRef ref="ConsoleAppender" /> -->
</Logger>
<Logger name="com.Test.BulkSolve.Utils.*" level="info" >
<AppenderRef ref="FileAppender" />
<!-- <AppenderRef ref="ConsoleAppender" /> -->
</Logger>
<Root level="info">
<!-- <AppenderRef ref="ConsoleAppender" /> -->
<AppenderRef ref="FileAppender"/>
</Root>
</Loggers>
</Configuration>```
Can any one suggest me what i did wrong here. My final goal is to display the logging inside logg file, when the operations are performed w.r.t the service.