GitHub user geomacy opened a pull request:

    https://github.com/apache/brooklyn-server/pull/940

    WIP Do not merge.  Add mapped diagnostic context with entity ids to logs

    Adds a mapped diagnostic context to (some) log messages.
    
    Basically if a task has a context entity this adds a field to log messages 
with a list of the ids of the entity and its ancestors up to the application. 
For example in the output from the `ApplicationLoggingTest` below, we get
    
    ```
    2018-01-23 11:52:20,118 INFO  [i6hk2jll5n, z2scr3kczj, hn242jl6bi]     
Hello from entity hn242jl6bi
    2018-01-23 11:52:20,118 INFO  [i6hk2jll5n, z2scr3kczj]   Hello from 
entity z2scr3kczj
    2018-01-23 11:52:20,118 INFO  [i6hk2jll5n] Hello world
    2018-01-23 11:52:20,128 INFO  [i6hk2jll5n] Goodbye cruel world
    2018-01-23 11:52:20,128 INFO  [i6hk2jll5n, z2scr3kczj]   Goodbye from 
entity z2scr3kczj
    2018-01-23 11:52:20,129 INFO  [i6hk2jll5n, z2scr3kczj, hn242jl6bi]     
Goodbye from entity hn242jl6bi
    ```
    
    This is basically a "proof of concept" to add entity ids to related logs.  
It's not ready to merge yet - the test doesn't assert on the logs, still 
working on that (LogWatcher doesn't pick up on the formatting).  
    
    Also while the output from this change does add entity ids into a good 
number of log messages, there are other messages  where the ids don't get 
added.  These are probably going through paths in the code that aren't 
addressed here.  Nevertheless I think this is worth putting up for people to 
look at.
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/geomacy/brooklyn-server logging-investigations

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/940.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #940
    
----
commit dff3fcf683162b84a9a44d2ecd154883e7b179ec
Author: Geoff Macartney <geoff.macartney@...>
Date:   2018-01-19T18:01:55Z

    Add code that gives a working MDC output in test
    
    2018-01-23 11:52:20,118 INFO  [i6hk2jll5n, z2scr3kczj, hn242jl6bi]     
Hello from entity hn242jl6bi
    2018-01-23 11:52:20,118 INFO  [i6hk2jll5n, z2scr3kczj]   Hello from entity 
z2scr3kczj
    2018-01-23 11:52:20,118 INFO  [i6hk2jll5n] Hello world
    2018-01-23 11:52:20,128 INFO  [i6hk2jll5n] Goodbye cruel world
    2018-01-23 11:52:20,128 INFO  [i6hk2jll5n, z2scr3kczj]   Goodbye from 
entity z2scr3kczj
    2018-01-23 11:52:20,129 INFO  [i6hk2jll5n, z2scr3kczj, hn242jl6bi]     
Goodbye from entity hn242jl6bi

commit 42afe00cc892b6d136533635ed0ba5378a1734e9
Author: Geoff Macartney <geoff.macartney@...>
Date:   2018-01-23T12:24:25Z

    Add context to main stdout appender

----


---

Reply via email to