CuukyOfficial / VaroPlugin

Ein sehr funktionsreiches und performantes ODV & Varo Plugin mit API u.v.m.
https://docs.varoplugin.de
GNU Affero General Public License v3.0
17 stars 21 forks source link

Integrate Log4j for Enhanced Logging #93

Closed ProfessorSam closed 5 months ago

ProfessorSam commented 5 months ago

I don't know how actively this repository is maintained, but I have noticed some flaws in your logging approach.

Problem: The current logging mechanism in the project primarily uses System.out.println statements for outputting messages to the console. This approach lacks flexibility and control over log levels, formatting, and destinations (e.g., custom log appender).

Desired Outcome: Replace the current logging mechanism with Log4j to provide a more robust and configurable logging solution. This includes the ability to log messages at different levels (e.g., INFO, WARN, ERROR), format log messages, and direct logs to various outputs (e.g., console, file, database).

Current Implementation: The code uses System.out.println statements for logging, which is not ideal for production environments. For example, in the onEnable and onDisable methods, various messages are printed to the console using System.out.println.

Proposed Solution: Integrate Log4j into the project to replace the current logging mechanism. This involves getting the plugin logger from the current plugin instance via the JavaPlugin#getLogger() method and using methods like warn, info, debug, etc.

Almighty-Satan commented 5 months ago

This repository is still actively being maintained, but development is usually very slow. I agree that using System.out.println (and Throwable#printStackTrace) for logging is not great, but fixing it is relatively low priority for me. Do you have a specific use case where the usage of System.out.println causes a problem (apart from cosmetic issues)?

ProfessorSam commented 5 months ago

I completely understand that addressing the logging mechanism might not be the highest priority at the moment. However, improving the logging approach can significantly benefit the project in the long run, especially regarding maintainability and troubleshooting.

One aspect worth considering is the capability to direct logs to multiple destinations beyond just the console. For instance, we might want to log certain messages to a file or even a database for easier monitoring and analysis. Integrating Log4j would allow us to configure custom appenders to achieve this flexibility seamlessly.

Moreover, adopting industry-standard logging practices, like using a proper logger, not only enhances the project's professionalism but also aligns with best practices in software development. It offers finer control over log levels, which can be invaluable when diagnosing issues in production environments.

Almighty-Satan commented 5 months ago

I'm closing this issue as we will probably not fix this in the near future, however we are always open to PRs. But please refrain from using LLMs to generate unnecessarily long-winded responses in the future.