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 "Gökalp Kuşçu (JIRA)" <ji...@apache.org> on 2015/01/17 04:57:34 UTC
[jira] [Commented] (LOG4J2-925) Log4j2 %rThrowable{full} not
prinitng getLocalizedMessage
[ https://issues.apache.org/jira/browse/LOG4J2-925?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14281200#comment-14281200 ]
Gökalp Kuşçu commented on LOG4J2-925:
-------------------------------------
It uses RootThrowablePatternConverter, i think, problem is format method.
Exception stacktrace has "\n\t" line.seperator. But Constants.LINE_SEPARATOR returns different value.(\r\n)
{code:title=RootThrowablePatternConverter.java|borderStyle=solid}
....
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
ThrowableProxy proxy = null;
if (event instanceof Log4jLogEvent) {
proxy = ((Log4jLogEvent) event).getThrownProxy();
}
final Throwable throwable = event.getThrown();
if (throwable != null && options.anyLines()) {
if (proxy == null) {
super.format(event, toAppendTo);
return;
}
final String trace = proxy.getCauseStackTraceAsString(options.getPackages());
final int len = toAppendTo.length();
if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
toAppendTo.append(' ');
}
if (!options.allLines() || !Constants.LINE_SEPARATOR.equals(options.getSeparator())) {
final StringBuilder sb = new StringBuilder();
//exception stacktrace has "\n\t" line.seperator. But Constants.LINE_SEPARATOR returns different value
//############################################################
final String[] array = trace.split(Constants.LINE_SEPARATOR); // \n\t
//############################################################
final int limit = options.minLines(array.length) - 1;
for (int i = 0; i <= limit; ++i) {
sb.append(array[i]);
if (i < limit) {
sb.append(options.getSeparator());
}
}
toAppendTo.append(sb.toString());
} else {
toAppendTo.append(trace);
}
}
}
...
{code}
http://logging.apache.org/log4j/2.0/manual/layouts.html for short.localizedMessage.
------------------------
{code}
<property name="consolelayoutPattern">%-5p %-30.30c{2} %m%n%throwable{short.localizedMessage}</property>
{code}
> Log4j2 %rThrowable{full} not prinitng getLocalizedMessage
> ---------------------------------------------------------
>
> Key: LOG4J2-925
> URL: https://issues.apache.org/jira/browse/LOG4J2-925
> Project: Log4j 2
> Issue Type: Bug
> Components: Layouts
> Reporter: Alireza Fattahi
>
> It seems that the %rThrowable{full} pattern will not use {{getLocalizedMessage()}} by default, while the %Throwable{full} will out put it.
> The rThrowable{short.localizedMessage} is not working
> My pattern is:
> {code:xml}
> <property name="consolelayoutPattern">%-5p %-30.30c{2} %m%n%rThrowable{full}</property>
> {code}
> Any suggestion ?!
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org