[ 
https://issues.apache.org/jira/browse/SLING-3049?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16223417#comment-16223417
 ] 

Chetan Mehrotra commented on SLING-3049:
----------------------------------------

Created PR https://github.com/apache/sling-org-apache-sling-commons-log/pull/1

This approach uses a 
[WeavingHook|https://osgi.org/javadoc/r4v43/core/org/osgi/framework/hooks/weaving/WeavingHook.html]
 to determine class to bundle mapping. Via hook it create a mapping of class 
package with bundle version. Then it hooks into the Logback rendering logic to 
add the version info as part of stacktrace. 

The log entry would look like below
{noformat}
28.10.2017 15:52:34.060 *ERROR* [0:0:0:0:0:0:0:1 [1509186154052] POST 
/bin/cpm/nodes/node.create.json HTTP/1.1] 
com.composum.sling.core.servlet.ServletOperationSet Access denied.
javax.jcr.AccessDeniedException: Access denied.
        at 
org.apache.jackrabbit.oak.jcr.security.AccessManager.checkPermissions(AccessManager.java:71)
 [1.6.4]
        at 
org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:295) 
[1.6.4]
        at 
org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:264) 
[1.6.4]
        at 
org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:208)
 [1.6.4]
        at 
org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) 
[1.6.4]
        at 
org.apache.jackrabbit.oak.jcr.session.NodeImpl.addNode(NodeImpl.java:264) 
[1.6.4]
        at 
com.composum.sling.nodes.servlet.NodeFactory$DefaultStrategy.createNode(NodeFactory.java:68)
 [1.8.2]
        at 
com.composum.sling.nodes.servlet.NodeFactory.createNode(NodeFactory.java:51) 
[1.8.2]
        at 
com.composum.sling.nodes.servlet.NodeServlet$CreateOperation.doIt(NodeServlet.java:1083)
 [1.8.2]
        at 
com.composum.sling.core.servlet.ServletOperationSet.doPost(ServletOperationSet.java:173)
 [1.8.2]
        at 
com.composum.sling.core.servlet.AbstractServiceServlet.doPost(AbstractServiceServlet.java:85)
 [1.8.2]
        at 
org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:149)
 [2.16.2]
        at 
org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:346)
 [2.16.2]
        at 
org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:378)
 [2.16.2]
        at 
org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:552) 
[2.6.8]
        at 
org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44)
 [2.6.8]
        at 
org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:77)
 [2.6.8]
        at 
org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:282)
 [2.6.8]
        at 
org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
 [2.6.8]
        at 
org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:77)
 [2.6.8]
        at 
org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:107)
 [2.6.8]
        at 
org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
 [2.6.8]
        at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:138) 
[2.5.8]
{noformat}

With this feature enabled on a larger setup I did not find any delay in 
startup/restart. On such a setup it was having mapping for 2000+ packages. This 
approach does not add much over head as mapping is cached.

[~karlpauls] [~cziegeler] [~ianeboston] Please review the approach. This 
feature should not be adding much overhead and would prove useful when users 
provide exception message on mailing list to discuss the issue. 

PS: If required we can also include bundle name. But that may not be very useful

> Make Logback Stacktrace Packaging data support OSGi aware
> ---------------------------------------------------------
>
>                 Key: SLING-3049
>                 URL: https://issues.apache.org/jira/browse/SLING-3049
>             Project: Sling
>          Issue Type: Improvement
>          Components: Commons
>            Reporter: Chetan Mehrotra
>            Assignee: Chetan Mehrotra
>              Labels: logback
>         Attachments: SLING-3049.patch, 
> buildbot-exceptions-while-stopping-jetty.txt
>
>
> Logback provides a useful feature where it dumps the Class packaging Data 
> along with the stacktrace [1]. This provides a quick view of the location 
> from where classes in a given stacktrace are coming. Its default logic does 
> not work properly in OSGi env. Hence it would be useful to patch its logic to 
> become OSGi aware
> [1] http://logback.qos.ch/reasonsToSwitch.html#packagingData



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to