Pierre Smeyers created LOGBACK-1296:
---------------------------------------

             Summary: Compute hash value from exception stacks
                 Key: LOGBACK-1296
                 URL: https://jira.qos.ch/browse/LOGBACK-1296
             Project: logback
          Issue Type: New Feature
          Components: logback-classic
    Affects Versions: 1.3.0
            Reporter: Pierre Smeyers
            Assignee: Logback dev list
            Priority: Minor


Comparing two stack traces can be somewhat painful if you want to check whether 
two errors are - or not - occurrences of the same error.

This new feature aims at computing a hash (hexadecimal integer) for each 
individual error stack trace, and inline them in the stack trace and/or output 
it as an individual conversion word.

Ex:

{{{color:#ff0000}#07e70d1e{color}> com.xyz.MyApp$MyClient$MyClientException: An 
error occurred while getting the things}}
{{  at com.xyz.MyApp$MyClient.getTheThings(MyApp.java:26)}}
{{  at com.xyz.MyApp.test_logging(MyApp.java:16)}}
{{  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)}}
{{  at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)}}
{{  at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)}}
{{  at java.lang.reflect.Method.invoke(Method.java:498)}}
{{  at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)}}
{{  at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)}}
{{  ...}}
{{Caused by: {color:#ff0000}#393b506a{color}> 
com.xyz.MyApp$HttpStack$HttpError: I/O error on GET request for 
http://dummy/things}}
{{  at com.xyz.MyApp$HttpStack.get(MyApp.java:40)}}
{{  at com.xyz.MyApp$MyClient.getTheThings(MyApp.java:24)}}
{{  ... 23 common frames omitted}}
{{Caused by: {color:#ff0000}#d6db326f{color}> java.net.SocketTimeoutException: 
Read timed out}}
{{  at com.xyz.MyApp$HttpStack.get(MyApp.java:38)}}
{{  ... 24 common frames omitted}}

 

Those hash will help you detect several occurrences of the same error, as it is 
highly probable that two errors with the same hash will be - indeed - 
occurrences of the same error.

I've already open-sourced this feature in a separate library (see 
[https://github.com/Orange-OpenSource/orange-mathoms-logging] ).

It is very useful (especially when indexing this hash into Elasticsearch, to 
track the error history, frequency, ...) and quite used internally at Orange, 
and I though it would be nice to contribute to Logback...

 

An implementation proposal is ready in my GitHub account

See: [https://github.com/pismy/logback/tree/stack-hash]

Let me know if I should create a PR now or start a discussion about the design.

Thanks,

Pierre.



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)
_______________________________________________
logback-dev mailing list
logback-dev@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-dev

Reply via email to