Skip to content

feat: configure logging and replace println/stacktraces#1229

Open
4Empty4 wants to merge 1 commit into
mate-academy:masterfrom
4Empty4:master
Open

feat: configure logging and replace println/stacktraces#1229
4Empty4 wants to merge 1 commit into
mate-academy:masterfrom
4Empty4:master

Conversation

@4Empty4
Copy link
Copy Markdown

@4Empty4 4Empty4 commented Mar 17, 2026

  • add log4j with console and rolling file appenders
  • ignore generated log files in git
  • replace println and printStackTrace with logger calls
  • complete logging TODOs in services and main

- add log4j with console and rolling file appenders
- ignore generated log files in git
- replace println and printStackTrace with logger calls
- complete logging TODOs in services and main
Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Excellent work on implementing the logging feature! You've correctly configured Log4j, replaced system outputs, and handled exceptions as required, meeting all the core requirements. I am approving your solution.

For future improvement, consider making your log messages in AuthenticationServiceImpl.java more structured by including method parameters for easier debugging. Also, it's a good practice to avoid hardcoding values in log messages, like the username in Main.java, and to ensure files end with a newline. These are minor points, but they contribute to cleaner code. Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

@Override
public User login(String login, String password) throws AuthenticationException {
//TODO: add corresponding log message about method login was called
logger.info("login() called for user: " + login);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This log message is informative, but it could be more structured to better align with the 'Good example' from the checklist. Consider including the parameter name in the message for clarity, for example: "login() method called with login='" + login + "'".

logger.info("login() called for user: " + login);
User user = findByLogin(login);
if (!user.getPassword().equals(password)) {
logger.warn("Invalid credentials for user: " + login);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This warning message is good because it includes the username. To make it even more helpful, you could be more specific about why it failed. For example: "Invalid password attempt for user: " + login.

logger.warn("Invalid credentials for user: " + login);
throw new AuthenticationException("Username or password are incorrect");
}
logger.info("User authenticated: " + login);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a good log entry for a successful event. To improve consistency with other log messages, consider a more structured format like: "User authenticated successfully: " + login.

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.

2 participants