【发布时间】:2019-04-08 14:00:47
【问题描述】:
我正面临着我无法解释的事情。 我在 pom.xml 的 dev 和 prod 配置文件中都将日志级别设置为 INFO。
当我使用nohup /home/dev/workspace/myapp/target/myapp.war --spring.profiles.active=dev 运行网络应用程序时
下面的指令双除= 1/0;在日志控制台中显示错误:
08/04/2019 - 15:37 [ERROR] com.myapp.rh.aop.logging.LoggingAspect - Exception in com.myapp.rh.service.MailService.sendRetourCandidatureEmail() with cause = null and exception {}
java.lang.ArithmeticException: / by zero
当我使用 prod 配置文件运行时:
nohup /home/dev/workspace/myapp/target/myapp.war --spring.profiles.active=prod
日志控制台中不显示任何内容。我不明白为什么,因为我在两个配置文件中设置了相同的日志级别。
LogginAspect.java:
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT)) {
log.error("Exception in {}.{}() with cause = {} and exception {}", joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(), e.getCause(), e);
} else {
log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(), e.getCause());
}
}
【问题讨论】: