Skip to content

config: improve logback configuration with async appenders and env-based properties#247

Open
vLuckyyy wants to merge 1 commit intomasterfrom
logback-update
Open

config: improve logback configuration with async appenders and env-based properties#247
vLuckyyy wants to merge 1 commit intomasterfrom
logback-update

Conversation

@vLuckyyy
Copy link
Member

…sed properties

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @vLuckyyy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the Logback configuration to enhance logging flexibility, performance, and maintainability. By introducing environment-variable-driven properties and asynchronous appenders, the system can now adapt more easily to different deployment environments while minimizing the performance impact of logging operations. The updated file rolling policy ensures efficient log management, and granular control over third-party library logging provides clearer insights into application behavior.

Highlights

  • Environment-based Configuration: Introduced environment variables for key logging parameters such as application name, log directory, and various log levels, allowing for more flexible and dynamic configuration.
  • Asynchronous Appenders: Implemented asynchronous appenders for both console and file logging, which helps to offload logging operations from the main application threads, improving performance and responsiveness, especially for I/O-bound logging.
  • Enhanced File Rolling Policy: Updated the file appender to use a SizeAndTimeBasedRollingPolicy, enabling log files to roll over based on both size (20MB) and time (daily), with compression and a history retention of 30 days or 2GB total size.
  • Granular JDA Logging Control: Added specific logger configurations for JDA (Java Discord API) and its internal components, as well as related HTTP/WebSocket libraries (com.neovisionaries.ws.client, okhttp3, okio), allowing for fine-grained control over their log levels.
  • Standardized Log Patterns: Defined distinct and more descriptive pattern layouts for console and file appenders, improving readability and consistency of log output.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/main/resources/logback.xml
    • Added contextName for the Logback configuration.
    • Introduced properties for APP_NAME, LOG_DIR, ROOT_LOG_LEVEL, JDA_LOG_LEVEL, and JDA_INTERNAL_LOG_LEVEL with default values.
    • Defined CONSOLE_PATTERN and FILE_PATTERN properties for log output formatting.
    • Replaced the implicit STDOUT appender with an explicit CONSOLE appender using the new CONSOLE_PATTERN.
    • Modified the FILE appender to use SizeAndTimeBasedRollingPolicy with maxFileSize, maxHistory, totalSizeCap, and cleanHistoryOnStart.
    • Updated the FILE appender's encoder to use FILE_PATTERN and UTF-8 charset.
    • Added ASYNC_CONSOLE and ASYNC_FILE appenders to wrap the CONSOLE and FILE appenders, respectively, with queue sizes and neverBlock set to true.
    • Configured specific log levels for net.dv8tion.jda, net.dv8tion.jda.internal, com.neovisionaries.ws.client, okhttp3, and okio.
    • Updated the root logger to use the ROOT_LOG_LEVEL property and reference the new ASYNC_CONSOLE and ASYNC_FILE appenders.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@vLuckyyy vLuckyyy marked this pull request as ready for review February 23, 2026 22:37
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly improves the logging configuration by introducing environment-based properties, asynchronous appenders for better performance, and a more robust log rotation strategy. The changes make the logging setup much more flexible and suitable for a production environment. I have one minor suggestion to clean up the configuration slightly.

<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" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The okio library is a dependency of OkHttp and provides efficient I/O primitives, but it does not have its own logging capabilities that are configured via SLF4J/Logback. Therefore, this <logger> configuration for okio has no effect and can be removed to keep the configuration clean and concise.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04f65e2bda

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<root level="info">
<appender name="ASYNC_FILE" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>8192</queueSize>
<neverBlock>true</neverBlock>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid dropping logs when async file queue fills

Setting neverBlock to true on 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant