Logstash is not printing the whole exception log in a single message

Below is my exception log which I'm sending to logstash through filebeat but it only prints the single line of it. It is not considering the whole message:

Failed to complete request: org.springframework.web.multipart.MultipartException: Current request is not a multipart request

2024-01-08 11:42:47 [http-nio-8080-exec-8] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] -

				Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Current request is not a multipart request] with root cause

org.springframework.web.multipart.MultipartException: Current request is not a multipart request

	at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValueInternal(RequestParamMethodArgumentResolver.java:210)

	at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:193)

	at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:114)

	at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122)

	at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:179)

	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:146)

	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)

	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)

	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)

	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)

	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)

	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)

	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)

	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)

	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)

	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)

	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)

	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)

	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)

	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)

	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)

	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)

	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)

	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732)

	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)

	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)

	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

	at java.lang.Thread.run(Thread.java:748)

As you can see the below Screenshot

Hi,

To solve this, you need to configure multiline settings in your Filebeat configuration. Here's a sample configuration that you can use as a starting point:

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /path/to/your/log/file.log
  multiline.pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
  multiline.negate: true
  multiline.match: after

Ref:
Manage multiline messages | Filebeat Reference [8.11] | Elastic

But will it capture the error logs as well. This is exception which occurs sometimes I'm actually sending error logs to logstash and along with that when exception log appears it doesn't get ingested completely inside the message filed. Below is the error log:

                                GET "/nginx_status", parameters={}
2024-01-08 16:56:30 [http-nio-8080-exec-4] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping -
                                Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
2024-01-08 16:56:30 [http-nio-8080-exec-4] DEBUG o.s.w.s.r.ResourceHttpRequestHandler -
                                Resource not found
2024-01-08 16:56:30 [http-nio-8080-exec-4] DEBUG o.s.web.servlet.DispatcherServlet -
                                Completed 404 NOT_FOUND
2024-01-08 16:56:30 [http-nio-8080-exec-4] DEBUG o.s.web.servlet.DispatcherServlet -
                                "ERROR" dispatch for GET "/error", parameters={}
2024-01-08 16:56:30 [http-nio-8080-exec-4] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping -
                                Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest)
2024-01-08 16:56:30 [http-nio-8080-exec-4] DEBUG o.s.w.s.m.m.a.HttpEntityMethodProcessor -
                                Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
2024-01-08 16:56:30 [http-nio-8080-exec-4] DEBUG o.s.w.s.m.m.a.HttpEntityMethodProcessor -
                                Writing [{timestamp=Mon Jan 08 16:56:30 IST 2024, status=404, error=Not Found, path=/nginx_status}]
2024-01-08 16:56:30 [http-nio-8080-exec-4] DEBUG o.s.web.servlet.DispatcherServlet -
                                Exiting from "ERROR" dispatch, status 404

If your log is a multiline log you need to configure the multline in filebeat as mentioned, this will make filebeat aggregate the lines that does not start with a date.

Have you tested it? Change your filebeat configuration and report back if it does not work.

Yes I checked everything works fine but my first exception is one single event but I'm getting it in two parts. As I have mentioned below the exception this should be considered as one single event.

Failed to complete request: org.springframework.web.multipart.MultipartException: Current request is not a multipart request

2024-01-08 11:42:47 [http-nio-8080-exec-8] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] -

				Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Current request is not a multipart request] with root cause

org.springframework.web.multipart.MultipartException: Current request is not a multipart request

	at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValueInternal(RequestParamMethodArgumentResolver.java:210)

	at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:193)

	at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:114)

	at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122)

	at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:179)

	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:146)

	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)

	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)

	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)

	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)

	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)

	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)

	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)

	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)

	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)

	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)

	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)

	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)

	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)

	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)

	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)

	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)

	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)

	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732)

	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)

	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)

	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

	at java.lang.Thread.run(Thread.java:748)

But the first line of the exception is considered as one event and the rest are second. Please refer the below lines

Failed to complete request: org.springframework.web.multipart.MultipartException: Current request is not a multipart request

And another event looks like this

2024-01-08 11:42:47 [http-nio-8080-exec-8] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] -

				Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Current request is not a multipart request] with root cause

org.springframework.web.multipart.MultipartException: Current request is not a multipart request

	at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValueInternal(RequestParamMethodArgumentResolver.java:210)

	at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:193)

	at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:114)

	at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122)

	at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:179)

	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:146)

	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)

	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)

	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)

	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)

	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)

	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)

	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)

	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)

	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)

	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)

	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)

	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)

	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)

	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)

	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)

	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)

	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)

	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732)

	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)

	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)

	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

	at java.lang.Thread.run(Thread.java:748)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.