In our development time and in production we need to debug the functionality for resolve the issue.
Liferay gives OOTB logging functionality. Say I have ABController.java and I want to get log of this class then create one static log variable in Java class.
You have below option to log the value.
1. _log.debug() method : This log only can see when the debug option is selected for this class in control panel (we will see where you can change it)
2. _log.error() method : To display error message.
3. _log.info() method : This will always display log message.
4. _log.fatal() method : This will display fatal error message.
5. _log.warn() method : This message will display warnings.
You can enabled and disabled the log level of Class in Control panel. Go to Control panel -> Server Administration -> Log Levels. First search you class with full package in Update category tab and if you find the class then you can change log level from log level options. But if you don't find the Class then you can create your own category by click on Add category and add your class with full specified path and select log level you want to select.
In production, more logs may create performance issue so generally We will use _log.debug() method. When we need to test on production then enable debug log level for this class and after completion of debugging reset it to Off.
Useful links:
https://www.liferay.com/community/wiki/-/wiki/Main/How+to+configure+the+logs+in+Liferay
Liferay gives OOTB logging functionality. Say I have ABController.java and I want to get log of this class then create one static log variable in Java class.
private static Log _log = LogFactoryUtil.getLog(ABController.class);
1. _log.debug() method : This log only can see when the debug option is selected for this class in control panel (we will see where you can change it)
2. _log.error() method : To display error message.
3. _log.info() method : This will always display log message.
4. _log.fatal() method : This will display fatal error message.
5. _log.warn() method : This message will display warnings.
You can enabled and disabled the log level of Class in Control panel. Go to Control panel -> Server Administration -> Log Levels. First search you class with full package in Update category tab and if you find the class then you can change log level from log level options. But if you don't find the Class then you can create your own category by click on Add category and add your class with full specified path and select log level you want to select.
In production, more logs may create performance issue so generally We will use _log.debug() method. When we need to test on production then enable debug log level for this class and after completion of debugging reset it to Off.
Useful links:
https://www.liferay.com/community/wiki/-/wiki/Main/How+to+configure+the+logs+in+Liferay