[prev in list] [next in list] [prev in thread] [next in thread]
List: slf4j-dev
Subject: [slf4j-dev] [JIRA] Updates for SLF4J-479: JUL-SLF4J Bridge - sourceMethod not logged
From: "QOS.CH (JIRA)" <noreply-jira () qos ! ch>
Date: 2021-07-27 18:18:00
Message-ID: JIRA.15880.1577226044000.531.1627409880001 () Atlassian ! JIRA
[Download RAW message or body]
SLF4J / SLF4J-479 [Open]
JUL-SLF4J Bridge - sourceMethod not logged
==============================
Here's what changed in this issue in the last few minutes.
There is 1 comment.
View or comment on issue using this link
https://jira.qos.ch/browse/SLF4J-479
==============================
1 comment
------------------------------
Alex Antonov on 27/Jul/21 8:04 PM
There are a number of other implementations/wrappers, like SSLLogger, which don't \
pass the "format", and purely concatenate the Message string with the parameter \
strings.
Would be great to have an enhancement to the SLF4JBridgeHandler to check if \
parameters are present (not null and >0) and no provided ResourceBundle from the \
LogRecord, then just append the parameter.toString() values to the message instead.
{code:java}
private String getMessageI18N(LogRecord record) {
String message = record.getMessage();
if (message == null) {
return null;
}
ResourceBundle bundle = record.getResourceBundle();
if (bundle != null) {
try {
message = bundle.getString(message);
} catch (MissingResourceException e) {
}
}
Object[] params = record.getParameters();
// avoid formatting when there are no or 0 parameters. see also
// http://jira.qos.ch/browse/SLF4J-203
if (params != null && params.length > 0) {
if
try {
MessageFormat format = new MessageFormat(message);
if (format.getFormats().length > 0) {
message = MessageFormat.format(message, params);
} else {
StringJoiner joiner = new StringJoiner(", "); \\ This could be \
replaced to be a NEW LINE instead of a comma-space. for (int i = 0; i < \
params.length; i++) { joiner.add(params[i].toString();
}
message = message + ": " + joiner.toString();
}
} catch (IllegalArgumentException e) {
// default to the same behavior as in \
java.util.logging.Formatter.formatMessage(LogRecord) // see also \
http://jira.qos.ch/browse/SLF4J-337 return message;
}
}
return message;
} {code}
==============================
This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)
_______________________________________________
slf4j-dev mailing list
slf4j-dev@qos.ch
http://mailman.qos.ch/mailman/listinfo/slf4j-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic