Skip to content

Conversation

@sancheet230
Copy link

Description
This PR addresses a critical issue with logging in the generated Kafka consumer code. Previously, calls to logger.info(...) were made without a properly defined logger, which would cause compile-time errors. The fix introduces a standard logger initialization in the consumer declaration:

private static final Logger logger = Logger.getLogger(YourConsumerClass.class.getName());

This change ensures that all logging calls have a valid reference, aligning with Java best practices for logging. While this PR resolves the logging issue, please note that placeholders like recordFailure(ex) and the reference to ch (used in the consumer constructor) are still present and will need to be addressed in subsequent updates

Related issue(s)
Fixes #241

Signed-off-by: sancheet230 <sancheet.p24@medhaviskillsuniversity.edu.in>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@sonarqubecloud
Copy link

@sancheet230 sancheet230 changed the title fix logging initialization for kafka consumer generated code fix: logging initialization for kafka consumer generated code Mar 26, 2025
@sancheet230
Copy link
Author

@dalelane
Copy link
Collaborator

Can you explain what compiler error you're trying to solve, please?

As I understand the current intent behind the code, the logger is provided in the superclass. While I could perhaps see an argument for having separate loggers for every class rather than sharing, that's rather more subjective than the critical compile error you seem to be seeing.

@dalelane
Copy link
Collaborator

... I could perhaps see an argument for having separate loggers for every class rather than sharing ...

Further to that, if we go with a separate-loggers approach, I think it would be better to do that across the board (i.e. what about producers) rather than just for the one isolated example.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation.

There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Jul 27, 2025
@github-actions github-actions bot closed this Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Logging Initialization Issue in Generated Kafka Consumer Code

2 participants