Skip to content

Commit

Permalink
feat: log to files again (additionally to stdout) #692
Browse files Browse the repository at this point in the history
  • Loading branch information
fengelniederhammer committed Apr 4, 2024
1 parent 0378b75 commit 1acedad
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
5 changes: 5 additions & 0 deletions lapis2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ How to execute the tests
* Install NPM dependencies: `npm install`
* Generate a Typescript client for LAPIS: `npm run generateLapisClient`
* Execute the tests: `npm run test`

## Logs

LAPIS logs to rotating files in `./logs` and to stdout.
In the Docker container, log files are stored in `/workspace/logs`
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ class LapisSpringConfig {
@Bean
fun logFilter(): CommonsRequestLoggingFilter {
val filter = CommonsRequestLoggingFilter()
filter.setIncludeQueryString(true)
filter.setIncludePayload(true)
filter.setMaxPayloadLength(10000)
filter.setIncludeHeaders(false)
return filter
}
Expand Down
39 changes: 34 additions & 5 deletions lapis2/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
<configuration>

<property name="PATTERN" value="%date %level [%thread] [%X{RequestId}] %class: %message%n"/>
<property name="LOG_FILE" value="LAPIS"/>
<property name="STATISTICS_LOG_FILE" value="statistics"/>
<property name="LOG_DIR" value="logs"/>
<property name="PATTERN" value="%date %level [%thread] %class: %message%n"/>

<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_DIR}/${LOG_FILE}.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>${PATTERN}</Pattern>
</encoder>

<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_DIR}/archived/${LOG_FILE}-%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
<maxFileSize>10GB</maxFileSize>
<maxHistory>0</maxHistory>
</rollingPolicy>
</appender>

<appender name="StatisticsRollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_DIR}/${STATISTICS_LOG_FILE}.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%message%n</Pattern>
</encoder>

<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_DIR}/archived/${STATISTICS_LOG_FILE}-%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
<maxFileSize>10GB</maxFileSize>
<maxHistory>0</maxHistory>
</rollingPolicy>
</appender>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
Expand All @@ -10,17 +39,17 @@

<root level="info">
<appender-ref ref="RollingFile"/>
<appender-ref ref="STDOUT"/>
</root>

<logger name="org.springframework.web.filter.CommonsRequestLoggingFilter" level="debug" additivity="false">
<appender-ref ref="RollingFile"/>
</logger>

<root level="info">
<appender-ref ref="STDOUT"/>
</root>
</logger>

<logger name="StatisticsLogger" level="info" additivity="false">
<appender-ref ref="RollingFile"/>
<appender-ref ref="StatisticsRollingFile"/>
<appender-ref ref="STDOUT"/>
</logger>

Expand Down

0 comments on commit 1acedad

Please sign in to comment.