You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2019/09/03 20:05:12 UTC

[GitHub] [logging-log4j2] jvz commented on a change in pull request #287: adding support for session attributes in log4j-web

jvz commented on a change in pull request #287: adding support for session attributes in log4j-web
URL: https://github.com/apache/logging-log4j2/pull/287#discussion_r320454341
 
 

 ##########
 File path: log4j-web/src/main/java/org/apache/logging/log4j/web/WebLookup.java
 ##########
 @@ -91,6 +93,18 @@ public String lookup(final LogEvent event, final String key) {
                     HttpServletRequest.class.cast(req).getParameter(name) : null;
         }
 
+        if (key.startsWith(SESSION_ATTR_PREFIX)) {
+            final ServletRequest req = getRequest();
+            if (HttpServletRequest.class.isInstance(req)) {
 
 Review comment:
   Why the reflection? You could change this to be:
   
   ```
   if (req instanceof HttpServletRequest) {
     final HttpSession session = ((HttpServletRequest) req).getSession(false);
     // ...
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services