This section includes the logging description in the framework.
Always consider adding logging to classes that could require debugging or monitoring. |
Basic Usage
You can use logging by
public class YourClass{
JKLogger logger=JKLoggerFactory.getLogger(getClass());
...
public void method(String param1){
logger.info("Calling method1() with param {}",param1);
....
...
logger.debug("End of method1()");
}
Note that the "{}" braces is used as placeholders for variables, and they are served by order
Recommendations
It is recommended to use logging as follows:
-
Public method: logger.info(); only once on every method
-
Non-public methods: logger.debug()
-
Most of the time you will not need to use logger.error() since it will be used internally by the framework in case of exceptions or failure.
-
It could be a good idea to have logger.debug at the end of each public methods for later performance tuning.
Logging Config File
A default logging configuration as available out of the box in the framework, and includes the following contents:
Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-core/logging.adoc - include::../_inc/logback.xml[]
For having custom logging configuration, create src/main/resources/logback.xml file which shall contain your custom configurations.
For unit testing, the logback file name should be named logback-test.xml. |