[ 
https://issues.apache.org/jira/browse/KNOX-1462?focusedWorklogId=650045&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-650045
 ]

ASF GitHub Bot logged work on KNOX-1462:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 13/Sep/21 14:24
            Start Date: 13/Sep/21 14:24
    Worklog Time Spent: 10m 
      Work Description: zeroflag commented on a change in pull request #488:
URL: https://github.com/apache/knox/pull/488#discussion_r707386400



##########
File path: 
gateway-i18n-logging-log4j/src/main/java/org/apache/knox/gateway/i18n/messages/loggers/log4j/Log4jMessageLogger.java
##########
@@ -37,42 +33,15 @@
 
   @Override
   public final boolean isLoggable( final MessageLevel level ) {
-    return logger.isEnabledFor( toLevel( level ) );
+    return logger.isEnabled( toLevel( level ) );
   }
 
   @Override
   public final void log( final StackTraceElement caller, final MessageLevel 
messageLevel, final String messageId, final String messageText, final Throwable 
thrown ) {
-    LoggingEvent event = new LoggingEvent(
-        /* String fqnOfCategoryClass */ CLASS_NAME,
-        /* Category logger */ logger,
-        /* long timeStamp */ System.currentTimeMillis(),
-        /* Level level */ toLevel( messageLevel ),
-        /* Object message */ messageText,
-        /* String threadName */ Thread.currentThread().getName(),
-        /* ThrowableInformation throwable */ toThrownInformation( thrown ),
-        /* String ndc */ null,
-        /* LocationInfo info */ toLocationInfo( caller ),
-        /* java.util.Map properties */ null );
-    logger.callAppenders( event );
-  }
-
-  private static ThrowableInformation toThrownInformation( final Throwable 
thrown ) {
-    ThrowableInformation info = null;
-    if( thrown != null ) {
-      info = new ThrowableInformation( thrown );
-    }
-    return info;
-  }
-
-  private static LocationInfo toLocationInfo( final StackTraceElement caller ) 
{
-    LocationInfo info = null;
-    if( caller != null ) {
-        info = new LocationInfo( caller.getFileName(), caller.getClassName(), 
caller.getMethodName(), Integer.toString(caller.getLineNumber()) );
-    }
-    return info;
+    logger.logMessage(toLevel(messageLevel), null, CLASS_NAME, caller, new 
SimpleMessage(messageText), thrown);

Review comment:
       @risdenk 
   
   ```
   amagyar-MBPloaner:test amagyar$ tail ~/Downloads/1gateway.log 
   2021-09-13 16:20:15,339 WARN  federation.jwt 
(AbstractJWTFilter.java:validateToken(339)) - Failed to verify the token 
signature of eyJraW...plfBXA (69d7e7ed...929fd3b25b82)
   2021-09-13 16:20:19,495 INFO  knox.gateway 
(KnoxLdapRealm.java:getUserDn(688)) - Computed userDn: 
uid=admin,ou=people,dc=hadoop,dc=apache,dc=org using dnTemplate for principal: 
admin
   2021-09-13 16:20:19,982 INFO  knox.gateway 
(CookieUtils.java:getCookiesForName(46)) - Unable to find cookie with name: 
original-url
   2021-09-13 16:20:19,989 INFO  service.knoxsso 
(WebSSOResource.java:addJWTHadoopCookie(386)) - JWT cookie successfully added.
   2021-09-13 16:20:19,990 INFO  service.knoxsso 
(WebSSOResource.java:getAuthenticationToken(278)) - About to redirect to 
original URL: https://localhost:8443/gateway/homepage/tokengen/index.html
   2021-09-13 16:20:20,368 WARN  federation.jwt 
(SSOCookieFederationFilter.java:init(95)) - Configuration for authentication 
provider URL is missing - will derive default URL.
   2021-09-13 16:20:20,467 INFO  service.knoxtoken 
(TokenResource.java:init(234)) - Server management of token state is enabled 
for the "homepage" topology.
   2021-09-13 16:20:21,705 INFO  service.knoxtoken 
(TokenResource.java:getAuthenticationToken(673)) - Knox Token service 
(homepage) issued token eyJqa3...WK-log (d651a8ba...dee52d5d3433)
   2021-09-13 16:20:30,610 INFO  token.state 
(AliasBasedTokenStateService.java:persistTokenState(243)) - Creating token 
state aliases
   2021-09-13 16:20:30,915 INFO  token.state 
(AliasBasedTokenStateService.java:persistTokenState(252)) - Created token state 
aliases for d651a8ba...dee52d5d3433
   amagyar-MBPloaner:test amagyar$ tail ~/Downloads/2gateway.log 
   2021-09-13T16:10:27,612 INFO  knox.gateway 
(CookieUtils.java:getCookiesForName(46)) - Unable to find cookie with name: 
original-url
   2021-09-13T16:10:27,619 INFO  service.knoxsso 
(WebSSOResource.java:addJWTHadoopCookie(386)) - JWT cookie successfully added.
   2021-09-13T16:10:27,620 INFO  service.knoxsso 
(WebSSOResource.java:getAuthenticationToken(278)) - About to redirect to 
original URL: https://localhost:8443/gateway/homepage/tokengen/index.html
   2021-09-13T16:10:27,825 WARN  federation.jwt 
(SSOCookieFederationFilter.java:init(95)) - Configuration for authentication 
provider URL is missing - will derive default URL.
   2021-09-13T16:10:27,923 INFO  service.knoxtoken 
(TokenResource.java:init(234)) - Server management of token state is enabled 
for the "homepage" topology.
   2021-09-13T16:10:32,237 INFO  service.knoxtoken 
(TokenResource.java:getAuthenticationToken(673)) - Knox Token service 
(homepage) issued token eyJqa3...XWUzNg (1ab3aafb...f2d5b0ba8466)
   2021-09-13T16:10:32,634 INFO  service.knoxtoken 
(TokenResource.java:getAuthenticationToken(673)) - Knox Token service 
(homepage) issued token eyJqa3...voLZGw (dec74aac...96b76aa1b8b7)
   2021-09-13T16:10:45,996 INFO  token.state 
(AliasBasedTokenStateService.java:persistTokenState(243)) - Creating token 
state aliases
   2021-09-13T16:10:46,608 INFO  token.state 
(AliasBasedTokenStateService.java:persistTokenState(252)) - Created token state 
aliases for dec74aac...96b76aa1b8b7
   2021-09-13T16:10:46,609 INFO  token.state 
(AliasBasedTokenStateService.java:persistTokenState(252)) - Created token state 
aliases for 1ab3aafb...f2d5b0ba8466
   amagyar-MBPloaner:test amagyar$ 
   ```
   
   I see one difference in the date time format there is a 'T' between the date 
and time in the log2j version. I'll check that why. Other than this it looks 
the same.
   
   I see no difference between the gateway-audit logs:
   
   ```
   amagyar-MBPloaner:test amagyar$ tail ~/Downloads/1gateway-audit.log
   21/09/13 16:20:20 
|||audit|[0:0:0:0:0:0:0:1]|tokengen|admin|||access|uri|/gateway/homepage/tokengen/index.html|success|Response
 status: 200
   21/09/13 16:20:20 
||0362085a-ccdb-4baf-8ec7-35aa9258da94|audit|[0:0:0:0:0:0:0:1]|tokengen||||access|uri|/gateway/homepage/tokengen/index.html|unavailable|Request
 method: GET
   21/09/13 16:20:20 
||0362085a-ccdb-4baf-8ec7-35aa9258da94|audit|[0:0:0:0:0:0:0:1]|tokengen|admin|||authentication|uri|/gateway/homepage/tokengen/index.html|success|
   21/09/13 16:20:20 
|||audit|[0:0:0:0:0:0:0:1]|tokengen|admin|||access|uri|/gateway/homepage/tokengen/index.html|success|Response
 status: 200
   21/09/13 16:20:20 
||3fa7c4b8-4d1b-4d22-bb8f-ab4c5d84ed14|audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN||||access|uri|/gateway/homepage/knoxtoken/api/v1/token/getTssStatus|unavailable|Request
 method: GET
   21/09/13 16:20:20 
||3fa7c4b8-4d1b-4d22-bb8f-ab4c5d84ed14|audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN|admin|||authentication|uri|/gateway/homepage/knoxtoken/api/v1/token/getTssStatus|success|
   21/09/13 16:20:20 
|||audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN|admin|||access|uri|/gateway/homepage/knoxtoken/api/v1/token/getTssStatus|success|Response
 status: 200
   21/09/13 16:20:21 
||099c85e8-1746-4017-804e-ce1c46914e69|audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN||||access|uri|/gateway/homepage/knoxtoken/api/v1/token?lifespan=P0DT1H0M|unavailable|Request
 method: GET
   21/09/13 16:20:21 
||099c85e8-1746-4017-804e-ce1c46914e69|audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN|admin|||authentication|uri|/gateway/homepage/knoxtoken/api/v1/token?lifespan=P0DT1H0M|success|
   21/09/13 16:20:21 
|||audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN|admin|||access|uri|/gateway/homepage/knoxtoken/api/v1/token?lifespan=P0DT1H0M|success|Response
 status: 200
   amagyar-MBPloaner:test amagyar$ tail ~/Downloads/2gateway-audit.log
   21/09/13 14:10:27 
|||audit|[0:0:0:0:0:0:0:1]|tokengen|admin|||access|uri|/gateway/homepage/tokengen/fonts/fontawesome/fontawesome-webfont.woff?v=3.2.1|success|Response
 status: 200
   21/09/13 14:10:27 
||648f99cb-66ad-4206-84c6-2422684aec2b|audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN||||access|uri|/gateway/homepage/knoxtoken/api/v1/token/getTssStatus|unavailable|Request
 method: GET
   21/09/13 14:10:27 
||648f99cb-66ad-4206-84c6-2422684aec2b|audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN|admin|||authentication|uri|/gateway/homepage/knoxtoken/api/v1/token/getTssStatus|success|
   21/09/13 14:10:27 
|||audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN|admin|||access|uri|/gateway/homepage/knoxtoken/api/v1/token/getTssStatus|success|Response
 status: 200
   21/09/13 14:10:32 
||89e5d866-1423-47b6-9138-0e179356ec2a|audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN||||access|uri|/gateway/homepage/knoxtoken/api/v1/token?lifespan=P0DT1H0M|unavailable|Request
 method: GET
   21/09/13 14:10:32 
||89e5d866-1423-47b6-9138-0e179356ec2a|audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN|admin|||authentication|uri|/gateway/homepage/knoxtoken/api/v1/token?lifespan=P0DT1H0M|success|
   21/09/13 14:10:32 
|||audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN|admin|||access|uri|/gateway/homepage/knoxtoken/api/v1/token?lifespan=P0DT1H0M|success|Response
 status: 200
   21/09/13 14:10:32 
||fab4d745-8f70-4013-8394-a3da40796716|audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN||||access|uri|/gateway/homepage/knoxtoken/api/v1/token?lifespan=P0DT1H0M|unavailable|Request
 method: GET
   21/09/13 14:10:32 
||fab4d745-8f70-4013-8394-a3da40796716|audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN|admin|||authentication|uri|/gateway/homepage/knoxtoken/api/v1/token?lifespan=P0DT1H0M|success|
   21/09/13 14:10:32 
|||audit|[0:0:0:0:0:0:0:1]|KNOXTOKEN|admin|||access|uri|/gateway/homepage/knoxtoken/api/v1/token?lifespan=P0DT1H0M|success|Response
 status: 200
   amagyar-MBPloaner:test amagyar$ 
   ```




-- 
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.

To unsubscribe, e-mail: dev-unsubscr...@knox.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 650045)
    Time Spent: 4h 10m  (was: 4h)

> Migrate from Log4j 1.x to 2.x
> -----------------------------
>
>                 Key: KNOX-1462
>                 URL: https://issues.apache.org/jira/browse/KNOX-1462
>             Project: Apache Knox
>          Issue Type: Improvement
>            Reporter: Kevin Risden
>            Assignee: Attila Magyar
>            Priority: Blocker
>             Fix For: 2.0.0
>
>          Time Spent: 4h 10m
>  Remaining Estimate: 0h
>
> Assigning to version 1.2.0 to have a discussion about it.
> Log4j 1.x went EOL in August 2015. JDK 9+ support (KNOX-1458) will require 
> Log4j 2 since Knox uses MDC for all the audit logging. More details about the 
> issue and migration are found here:
>  * [https://blogs.apache.org/logging/entry/moving_on_to_log4j_2]
>  * [https://logging.apache.org/log4j/2.x/manual/migration.html]
> Items of "concern"
>  * MDC migrate to ThreadContext
>  * log4j.properties need to migrate to log4j2.xml (or yaml or json)
> Benefits
>  * Async logging
>  * Dynamic reloading of configuration changes



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to