Logging Sins in Your Java application
When done properly, the log files can also save you a lot of time by providing clues into the cause of the problem, and into the state of the system at the time it happened. Overall, logging is certainly a foundational practice that provides significant benefits during the lifetime of the application so it can be tempting to start recording as much log data as you can.
With the help of the custom aspect, we can be very selective and pick the exact areas of the application where we actually need information in the logs. For example, if you want to log the start and end of particular methods, you can add an Aspect that will do this for every method that has a specified custom annotation. Always keep in mind that your logs will most certainly be read by a different developer or system administrator, and they need to understand what has happened in the application.
Using a Single Log File
The downside of only using one log file for the application is, that this will, over time, become quite large and difficult to work with. Simply put, choosing the right log level for the different logs in your system is one of the core things you need to get right to have a good experience understanding your logs.
To address this kind of architecture, we now have a new generation of logging helper tools in the ecosystem, such as Zipkin and Spring Cloud Sleuth. Not Logging with JSON. While logging in a plaintext format is very common, the advent of log storage and data analysis systems has shifted that towards JSON.
One can use also #jSparrow. jSparrow is a rule-based refactoring Tool with some rules to cope with these issues in a few minutes. Take a look and convince yourself of a powerfull Tool.
Source: https://dzone.com/articles/9-logging-sins-in-your-java-applications
?