You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Joern Huxhorn (JIRA)" <ji...@apache.org> on 2012/09/09 15:21:07 UTC

[jira] [Created] (LOG4J2-83) Please provide means to disable MDC functionality on a global level.

Joern Huxhorn created LOG4J2-83:
-----------------------------------

             Summary: Please provide means to disable MDC functionality on a global level.
                 Key: LOG4J2-83
                 URL: https://issues.apache.org/jira/browse/LOG4J2-83
             Project: Log4j 2
          Issue Type: New Feature
            Reporter: Joern Huxhorn


Disabling MDC evaluation can have drastic effects on event size while sending them over the wire or dumping them to disk.

When disabled, all calls to MDC-related methods will instead call NOP implementations, i.e. no ThreadLocals would be used at all.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


[jira] [Commented] (LOG4J2-83) Please provide means to disable MDC functionality on a global level.

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475680#comment-13475680 ] 

Ralph Goers commented on LOG4J2-83:
-----------------------------------

Please verify the fix and close it. If it doesn't fully implement what is required feel free to reopen it.
                
> Please provide means to disable MDC functionality on a global level.
> --------------------------------------------------------------------
>
>                 Key: LOG4J2-83
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-83
>             Project: Log4j 2
>          Issue Type: New Feature
>            Reporter: Joern Huxhorn
>            Assignee: Ralph Goers
>             Fix For: 2.0-beta2
>
>
> Disabling MDC evaluation can have drastic effects on event size while sending them over the wire or dumping them to disk.
> When disabled, all calls to MDC-related methods will instead call NOP implementations, i.e. no ThreadLocals would be used at all.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


[jira] [Commented] (LOG4J2-83) Please provide means to disable MDC functionality on a global level.

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13462379#comment-13462379 ] 

Ralph Goers commented on LOG4J2-83:
-----------------------------------

I have commit the change in revision 1389690 as described above. The Map in the LogEvent is now immutable and is null if the ThreadContextMap is empty.
                
> Please provide means to disable MDC functionality on a global level.
> --------------------------------------------------------------------
>
>                 Key: LOG4J2-83
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-83
>             Project: Log4j 2
>          Issue Type: New Feature
>            Reporter: Joern Huxhorn
>
> Disabling MDC evaluation can have drastic effects on event size while sending them over the wire or dumping them to disk.
> When disabled, all calls to MDC-related methods will instead call NOP implementations, i.e. no ThreadLocals would be used at all.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


[jira] [Commented] (LOG4J2-83) Please provide means to disable MDC functionality on a global level.

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461835#comment-13461835 ] 

Ralph Goers commented on LOG4J2-83:
-----------------------------------

I am not convinced that completely disabling the MDC is a good idea as it could lead to application breakage.  However, I am convinced that having the ThreadContext map be null in the LogEvent when there are no items in the Map is a very good idea. I plan on making that change and also plan on changing the Map stored in the LogEvent to be immutable.
                
> Please provide means to disable MDC functionality on a global level.
> --------------------------------------------------------------------
>
>                 Key: LOG4J2-83
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-83
>             Project: Log4j 2
>          Issue Type: New Feature
>            Reporter: Joern Huxhorn
>
> Disabling MDC evaluation can have drastic effects on event size while sending them over the wire or dumping them to disk.
> When disabled, all calls to MDC-related methods will instead call NOP implementations, i.e. no ThreadLocals would be used at all.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


[jira] [Closed] (LOG4J2-83) Please provide means to disable MDC functionality on a global level.

Posted by "Joern Huxhorn (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4J2-83?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joern Huxhorn closed LOG4J2-83.
-------------------------------


Looks good.
                
> Please provide means to disable MDC functionality on a global level.
> --------------------------------------------------------------------
>
>                 Key: LOG4J2-83
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-83
>             Project: Log4j 2
>          Issue Type: New Feature
>            Reporter: Joern Huxhorn
>            Assignee: Ralph Goers
>             Fix For: 2.0-beta2
>
>
> Disabling MDC evaluation can have drastic effects on event size while sending them over the wire or dumping them to disk.
> When disabled, all calls to MDC-related methods will instead call NOP implementations, i.e. no ThreadLocals would be used at all.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


[jira] [Commented] (LOG4J2-83) Please provide means to disable MDC functionality on a global level.

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13466364#comment-13466364 ] 

Ralph Goers commented on LOG4J2-83:
-----------------------------------

Joern - are the changes made enough to resolve your concerns?
                
> Please provide means to disable MDC functionality on a global level.
> --------------------------------------------------------------------
>
>                 Key: LOG4J2-83
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-83
>             Project: Log4j 2
>          Issue Type: New Feature
>            Reporter: Joern Huxhorn
>
> Disabling MDC evaluation can have drastic effects on event size while sending them over the wire or dumping them to disk.
> When disabled, all calls to MDC-related methods will instead call NOP implementations, i.e. no ThreadLocals would be used at all.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


[jira] [Resolved] (LOG4J2-83) Please provide means to disable MDC functionality on a global level.

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4J2-83?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers resolved LOG4J2-83.
-------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0-beta2
         Assignee: Ralph Goers

I have added support for setting system properties named "disableThreadContext", "disableThreadContextMap" , and "disableThreadContextStack". If disableThreadContext is set to true, pushes and puts will be ignored and no HashMaps or ContextStacks will be created. Similarly, if disableThreadContextMap is set to true then puts to the ThreadContextMap will be ignored and no Map will be created. Finally, if disableThreadContextStack is set to true then pushes will be ignored and no ContextStack will be created.

When these properties are set the ThreadLocals will still be created but will never have any values in them.
                
> Please provide means to disable MDC functionality on a global level.
> --------------------------------------------------------------------
>
>                 Key: LOG4J2-83
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-83
>             Project: Log4j 2
>          Issue Type: New Feature
>            Reporter: Joern Huxhorn
>            Assignee: Ralph Goers
>             Fix For: 2.0-beta2
>
>
> Disabling MDC evaluation can have drastic effects on event size while sending them over the wire or dumping them to disk.
> When disabled, all calls to MDC-related methods will instead call NOP implementations, i.e. no ThreadLocals would be used at all.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


[jira] [Commented] (LOG4J2-83) Please provide means to disable MDC functionality on a global level.

Posted by "Joern Huxhorn (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13466445#comment-13466445 ] 

Joern Huxhorn commented on LOG4J2-83:
-------------------------------------

Not really since the map wouldn't be empty at all in my cases.

We use MDC quite extensively, i.e. 10-15 key-value-pairs per event. We never ever read values from the MDC in our application code. The MDC is used purely for logging and not as some magic bucket for moving around objects across method calls.
Because of this, it would be feasible to disable MDC handling altogether. I suspect that most code is using the MDC like this, i.e. only writing, never reading (I've never seen any MDC values of libraries in my events).

Chances are quite high that an application would work exactly the same way with MDC disabled, just a lot faster. While disabling MDC could lead to application breakage if the application is indeed reading from the MDC I don't understand the problem about this. I'd just not disable the MDC in that case. This is comparable to pulling the network cable for an application that is using the network. Yep, it will cause breakage. Just don't do it in those cases.
                
> Please provide means to disable MDC functionality on a global level.
> --------------------------------------------------------------------
>
>                 Key: LOG4J2-83
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-83
>             Project: Log4j 2
>          Issue Type: New Feature
>            Reporter: Joern Huxhorn
>
> Disabling MDC evaluation can have drastic effects on event size while sending them over the wire or dumping them to disk.
> When disabled, all calls to MDC-related methods will instead call NOP implementations, i.e. no ThreadLocals would be used at all.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org