根据错误,它看起来像找到了日志文件,但是在返回之前,它在某些转换过程中失败了。 application.yml
logging:
path: logs
file: ${logging.path}/api.log
management:
endpoints:
logfile: logs/api.log
响应:
{
"error": {
"status": 500,
"message": "java.util.HashMap cannot be cast to
org.springframework.core.io.Resource",
"description": "uri=/api/logfile"
}
}
编辑
登录控制台
2019-06-28 16:02:31,221 DEBUG[https-jsse-nio-443-exec-4] LogFormatUtils.traceDebug:91 GET "/api-my/logfile", parameters={}
2019-06-28 16:02:31,222 DEBUG[https-jsse-nio-443-exec-4] AbstractHandlerMapping.getHandler:420 Mapped to Actuator web endpoint 'logfile'
2019-06-28 16:02:31,237 DEBUG[https-jsse-nio-443-exec-4] LogFormatUtils.traceDebug:91 Read "application/json;charset=UTF-8" to []
2019-06-28 16:02:31,244 DEBUG[https-jsse-nio-443-exec-4] PropertySourcesPropertyResolver.logKeyFound:115 Found key 'logging.path' in PropertySource 'configurationProperties' with value of type String
2019-06-28 16:02:31,250 DEBUG[https-jsse-nio-443-exec-4] AbstractMessageConverterMethodProcessor.writeWithMessageConverters:268 Using 'text/plain;charset=UTF-8', given [*/*] and supported [text/plain;charset=UTF-8]
2019-06-28 16:02:31,251 DEBUG[https-jsse-nio-443-exec-4] LogFormatUtils.traceDebug:91 Writing [{data=file [/Users/ibabur/workspaces/sts_workspace/myService/logs/api-my-logger.log], mess (truncated)...]
2019-06-28 16:02:31,252 DEBUG[https-jsse-nio-443-exec-4] ExceptionHandlerExceptionResolver.doResolveHandlerMethodException:403 Using @ExceptionHandler public final com.nenuphar.apimy.exception.ErrorDetails com.nenuphar.apimy.advice.CustomizedResponseEntityExceptionHandler.handleAllExceptions(java.lang.Exception,org.springframework.web.context.request.WebRequest)
2019-06-28 16:02:31,261 DEBUG[https-jsse-nio-443-exec-4] AbstractMessageConverterMethodProcessor.writeWithMessageConverters:268 Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json, application/cbor]
2019-06-28 16:02:31,262 DEBUG[https-jsse-nio-443-exec-4] LogFormatUtils.traceDebug:91 Writing [{error=com.nenuphar.apimy.exception.ErrorDetails@8743f2f}]
2019-06-28 16:02:31,273 WARN[https-jsse-nio-443-exec-4] AbstractHandlerExceptionResolver.logException:198 Resolved [java.lang.ClassCastException: java.util.HashMap cannot be cast to org.springframework.core.io.Resource]
2019-06-28 16:02:31,274 DEBUG[https-jsse-nio-443-exec-4] FrameworkServlet.logResult:1130 Completed 500 INTERNAL_SERVER_ERROR
2019-06-28 16:02:31,277 DEBUG[https-jsse-nio-443-exec-4] ExceptionTranslationFilter.doFilter:121 Chain processed normally
2019-06-28 16:02:31,278 DEBUG[https-jsse-nio-443-exec-4] SecurityContextPersistenceFilter.doFilter:119 SecurityContextHolder now cleared, as request processing completed