-
-
Notifications
You must be signed in to change notification settings - Fork 1
config: improve logback configuration with async appenders and env-based properties #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vLuckyyy
wants to merge
1
commit into
master
Choose a base branch
from
logback-update
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,67 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <configuration> | ||
|
|
||
| <contextName>DiscordOfficer</contextName> | ||
|
|
||
| <property name="APP_NAME" value="${APP_NAME:-discord-officer}" /> | ||
| <property name="LOG_DIR" value="${LOG_DIR:-logs}" /> | ||
| <property name="ROOT_LOG_LEVEL" value="${ROOT_LOG_LEVEL:-INFO}" /> | ||
| <property name="JDA_LOG_LEVEL" value="${JDA_LOG_LEVEL:-INFO}" /> | ||
| <property name="JDA_INTERNAL_LOG_LEVEL" value="${JDA_INTERNAL_LOG_LEVEL:-WARN}" /> | ||
|
|
||
| <property name="CONSOLE_PATTERN" | ||
| value="%blue(╭ %d{HH:mm:ss.SSS}) %magenta(${APP_NAME}) %white(| %thread |) %highlight(%-5level) %cyan(%-40.40logger{40}) %white(→) %msg%n%ex" /> | ||
| <property name="FILE_PATTERN" | ||
| value="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] ${APP_NAME} %logger{50} - %msg%n%ex" /> | ||
|
|
||
| <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
| <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | ||
| <charset>UTF-8</charset> | ||
| <pattern>${CONSOLE_PATTERN}</pattern> | ||
| </encoder> | ||
| </appender> | ||
|
|
||
| <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
| <fileNamePattern>logs/logs-%d{yyyy-MM-dd}.log</fileNamePattern> | ||
| <file>${LOG_DIR}/app.log</file> | ||
| <append>true</append> | ||
|
|
||
| <maxHistory>90</maxHistory> | ||
| <totalSizeCap>3GB</totalSizeCap> | ||
| <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | ||
| <fileNamePattern>${LOG_DIR}/app.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern> | ||
| <maxFileSize>20MB</maxFileSize> | ||
| <maxHistory>30</maxHistory> | ||
| <totalSizeCap>2GB</totalSizeCap> | ||
| <cleanHistoryOnStart>true</cleanHistoryOnStart> | ||
| </rollingPolicy> | ||
|
|
||
| <encoder> | ||
| <pattern>[%d{dd-MM-yyyy HH:mm:ss}] %boldGreen(%-15.-15logger{0}) %highlight(%-6level) %msg%n</pattern> | ||
| <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | ||
| <charset>UTF-8</charset> | ||
| <pattern>${FILE_PATTERN}</pattern> | ||
| </encoder> | ||
| </appender> | ||
|
|
||
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
| <encoder> | ||
| <pattern>[%d{dd-MM-yyyy HH:mm:ss}] %boldGreen(%-15.-15logger{0}) %highlight(%-6level) %msg%n</pattern> | ||
| </encoder> | ||
| <!-- Async wrappers reduce blocking in JDA event/network threads --> | ||
| <appender name="ASYNC_CONSOLE" class="ch.qos.logback.classic.AsyncAppender"> | ||
| <queueSize>2048</queueSize> | ||
| <neverBlock>true</neverBlock> | ||
| <appender-ref ref="CONSOLE" /> | ||
| </appender> | ||
|
|
||
| <root level="info"> | ||
| <appender name="ASYNC_FILE" class="ch.qos.logback.classic.AsyncAppender"> | ||
| <queueSize>8192</queueSize> | ||
| <neverBlock>true</neverBlock> | ||
| <appender-ref ref="FILE" /> | ||
| <appender-ref ref="STDOUT" /> | ||
| </appender> | ||
|
|
||
| <!-- JDA and related HTTP/WebSocket dependencies --> | ||
| <logger name="net.dv8tion.jda" level="${JDA_LOG_LEVEL}" /> | ||
| <logger name="net.dv8tion.jda.internal" level="${JDA_INTERNAL_LOG_LEVEL}" /> | ||
| <logger name="com.neovisionaries.ws.client" level="WARN" /> | ||
| <logger name="okhttp3" level="WARN" /> | ||
| <logger name="okio" level="WARN" /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| <root level="${ROOT_LOG_LEVEL}"> | ||
| <appender-ref ref="ASYNC_CONSOLE" /> | ||
| <appender-ref ref="ASYNC_FILE" /> | ||
| </root> | ||
|
|
||
| </configuration> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting
neverBlocktotrueon the async file appender means log events are discarded once the queue is saturated (for example during bursty logging or slow disk I/O), and this configuration routes all root logging through async appenders only. That can silently lose warning/error evidence exactly during incidents, whereas the previous synchronous setup preserved those messages.Useful? React with 👍 / 👎.