Hi,
it may be a stupid question, but I could not find a way to solve this: I repeatedly get error messages in openhab.log for various reasons (which I hope to find some day and eliminate them all). The problem is that with each error the whole java call stack is usually included, like
2021-07-23 16:37:18.897 [WARN ] [s.impl.WebApplicationExceptionMapper] - javax.ws.rs.NotSupportedException: HTTP 415 Unsupported Media Type
at org.apache.cxf.jaxrs.utils.SpecExceptions.toNotSupportedException(SpecExceptions.java:109)
at org.apache.cxf.jaxrs.utils.ExceptionUtils.toNotSupportedException(ExceptionUtils.java:160)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:383)
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:181)
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
....
and so on. The call stack, not just quite unhelpful for debugging, is often very long, flooding the logs, causing huge log files of which I am really annoyed by now.
I wonder if there is a way to disable the inclusion of call stacks for the errors?
(I do not wish to disable any error messages, just want them to take no more than a single line in the logfile, so the above example would be no more than 2021-07-23 16:37:18.897 [WARN ] [s.impl.WebApplicationExceptionMapper] - javax.ws.rs.NotSupportedException: HTTP 415 Unsupported Media Type
)
Is this possible somehow?
Thanks, this should be exactly what I need! I just wonder where does the exception keyword need to be added precisely in OH3? I tried to add it to the end of the openhab.log <RollingFile ...> section of /var/lib/openhab/etc/log4j2.xml as
Thanks! In your examples (also confirmed in my case) replacing %m with %ex{…} also clears all messages from the logs. This essentially renders the whole log file useless, so not quite an option. If I add %ex{short} either before or after %m, the whole stack is included anyway.
Funny is that adding %nopex - which should also disable call trace handling - results in the “opex” entry in the log (preceded by a newline). Looks like these conversion keywords do not really work here as they should. Is there perhaps some special syntax with this xml-based configuration of OH3?