【发布时间】:2013-01-20 06:26:12
【问题描述】:
嗨,我很长时间以来一直怀疑是否在下面的方法(通常是辅助方法)中有记录器。
我们是否可以在方法中打印或者在调用方法的地方打印响应。
public String getAddNewUserUrl()
{
String url = null;
try
{
String mode = new ModeUtil().getMode();
String urlToGet = ("local".equalsIgnoreCase(mode) ||"staging".equalsIgnoreCase(mode)) ? "staging.url" : "live.url"
url = ResourceBundle.getBundle("ApplicationResources").getString(urlToGet);
log.info("The url is : " + url); // Can we use logs like this
}
catch(Exception e)
{
log.log( java.util.logging.Level.SEVERE , e.getMessage() , e );
log.error("Exception in the method getMode ::"+e.getMessage());
}
return url;
}
【问题讨论】:
-
有什么疑问?如果需要,您可以添加日志记录,否则您不需要。
-
我的意思是日志应该在方法中使用,或者我们可以打印返回响应的位置。
标签: java jakarta-ee spring-security