[ https://issues.apache.org/jira/browse/LOG4J2-1255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15147484#comment-15147484 ]
Remko Popma commented on LOG4J2-1255: ------------------------------------- Also, I found what looks like a bug in the implementation for these methods: * AbstractLogger.entryMsg(String format, MessageSupplier... paramSuppliers) * AbstractLogger.entryMsg(String format, Supplier<?>... paramSuppliers) * AbstractLogger.entryMsg(String format, Object... params) The first two methods obtain the Messages from the Supplier, but then call {{messageFactory.newMessage(format, messageArray)}}: {code} protected EntryMessage entryMsg(final String format, final MessageSupplier... paramSuppliers) { final int count = paramSuppliers == null ? 0 : paramSuppliers.length; final Object[] params = new Object[count]; for (int i = 0; i < count; i++) { params[i] = paramSuppliers[i].get(); // the Message object } return entryMsg(format, params); } {code} What you probably want is to use the formattedMessage strings of the supplied Message objects: {code} protected EntryMessage entryMsg(final String format, final MessageSupplier... paramSuppliers) { final int count = paramSuppliers == null ? 0 : paramSuppliers.length; final Object[] params = new Object[count]; for (int i = 0; i < count; i++) { params[i] = paramSuppliers[i].get().getFormattedMessage(); } return entryMsg(format, params); } {code} For defensive coding purposes, it is probably a good idea to ensure the same in the method that takes an Object[] array: {code} protected EntryMessage entryMsg(final String format, final Object... params) { final int count = params == null ? 0 : params.length; for (int i = 0; i < count; i++) { if (params[i] instanceof Message) { params[i] = ((Message) params[i]).getFormattedMessage(); } } ... // rest of method {code} > Logger.entry and Logger.exit should support Messages. > ----------------------------------------------------- > > Key: LOG4J2-1255 > URL: https://issues.apache.org/jira/browse/LOG4J2-1255 > Project: Log4j 2 > Issue Type: Improvement > Components: API > Affects Versions: 2.5 > Reporter: Ralph Goers > Assignee: Ralph Goers > Fix For: 2.6 > > > Logger.entry and Logger.exit currently do not support Message objects. This > reduces the flexibility of what can be logged on entry and exit to methods. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org