Reputation: 6271
I am not able to print the stack trace of the logger in my eclipse console.
log4j.properties
log4j.rootLogger=ERROR,console
#Console Appender
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%5p] [%t %d{hh:mm:ss}] (%F:%M:%L) %m%n
#Custom assignments
log4j.logger.controller=INFO,console
log4j.logger.service=INFO,console
#Disable additivity
log4j.additivity.controller=false
log4j.additivity.service=false
Service layer:
@Override
@Transactional(readOnly = true)
public List<MRPSDepositHistory> getDepositDetails(String searchCondition,
String searchText, String jtSorting, int startPaginationVal,
int endPaginationVal) {
String searchConditionEmpty = ManagementConstants.SEARCHCONDITIONNONE;
List<MRPSDepositHistory> fileNetStatus = new ArrayList<MRPSDepositHistory>();
try {
if (!searchConditionEmpty.equalsIgnoreCase(searchCondition)) {
if (searchCondition.equalsIgnoreCase(ManagementConstants.DEPOSITNUMBERKEY)) {
fileNetStatus = mrpsDepositHistoryDao.findByDepositNumber(
searchCondition, Short.valueOf(searchText), jtSorting,
startPaginationVal, endPaginationVal);
} else {
fileNetStatus = mrpsDepositHistoryDao.findBySearchText(
searchCondition, searchText, jtSorting,
startPaginationVal, endPaginationVal);
}
} else {
fileNetStatus = mrpsDepositHistoryDao.findByRestrictions(
searchCondition, searchText, jtSorting);
}
}
catch (NumberFormatException e) {
logger.error("ERROR:" + e);
}
return fileNetStatus;
}
Log getting printed in console now in eclipse:
[ERROR] [http-bio-8080-exec-9 03:46:16] (MrpsDepositHistoryServiceImpl.java:getDepositDetails:57) ERROR:java.lang.NumberFormatException: Value out of range. Value:"353453454" Radix:10
What I have made wrong in the above code.
Upvotes: 3
Views: 7530
Reputation: 6267
Replace
logger.error("ERROR:"+ e);
by
logger.error("ERROR:", e);
Former one actually concatenates strings and calls Logger.error(String)
which simply logs that concatenated string. But later one calls Logger.error(String, Throwable)
where the Throwable
(super class of Exception
) is managed separately.
Upvotes: 6