0

As per the error its looking like it found the log file but before returning it is failing during some conversion. application.yml

logging:
  path: logs
  file: ${logging.path}/api.log

management:
  endpoints:
    logfile: logs/api.log

Response:

{
  "error": {
  "status": 500,
  "message": "java.util.HashMap cannot be cast to 
             org.springframework.core.io.Resource",
  "description": "uri=/api/logfile"
  }
}

EDIT

Log in console

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
iBabur
  • 974
  • 12
  • 13
  • Hopefully there's a complete stack trace of the failure in your server's log. If there is, can you add it to the question please? – Andy Wilkinson Jun 27 '19 at 20:48
  • please see the logs added – iBabur Jun 28 '19 at 20:14
  • Is there a stack trace anywhere? Unfortunately those log lines don't show where the `ClassCastException` occurred. – Andy Wilkinson Jun 28 '19 at 21:25
  • Already there in exception messages, specific as below 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] – iBabur Jul 01 '19 at 17:29
  • Thanks, but that's not a stack trace. The stack trace shows the name of the class and method where the exception was thrown, and often the line number too. If you're not familiar with stack traces, [this](https://stackoverflow.com/a/3988794/1384297) is a great answer to learn more from. – Andy Wilkinson Jul 01 '19 at 18:30

0 Answers0