zeroflag commented on a change in pull request #488:
URL: https://github.com/apache/knox/pull/488#discussion_r708238056
##########
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:
In log4j1 ISO8601 datetime pattern doesn't contain the 'T' separator
between the date and time but in log4j2 it is there. I replaced the pattern to
`%d{yyyy-MM-dd' 'HH:mm:ss,SSS}` in the gateway's log4j config so that it looks
the same with log4j2.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]