Below logback-appenders.xml helps to create log file
<included>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{ISO8601} %-5p [%t][%c:%L] %m%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${app.logs}//.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${app.logs}//.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date{ISO8601} %-5p [%t][%c:%L] %m%n</pattern>
</encoder>
</appender>
</included>
Below logback-loggers.xml provides way to log spring & hibernate related content
<included>
<logger name="org.hibernate" level="WARN" />
<logger name="org.hibernate.type" level="WARN" />
<logger name="org.springframework" level="WARN" />
<logger name="org.springframework.web" level="WARN" />
<logger name="org.springframework.web.servlet" level="WARN" />
<logger name="org.hibernate.SQL" level="debug"/>
<logger name="org.hibernate.type" level="trace"/>
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</included>
No comments:
Post a Comment