Skip to content

Commit

Permalink
pattern in class scope instead of method scope
Browse files Browse the repository at this point in the history
  • Loading branch information
kmtong committed Feb 16, 2015
1 parent 246c51b commit 3e07aaf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/cwbase/logback/JSONEventLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class JSONEventLayout extends LayoutBase<ILoggingEvent> {

private StringBuilder buf = new StringBuilder(DEFAULT_SIZE);
private DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SZ");
private Pattern MDC_VAR_PATTERN = Pattern.compile("\\@\\{([^}]*)\\}");

private boolean locationInfo = false;
private int callerStackIdx = 0;
Expand Down Expand Up @@ -228,8 +229,7 @@ private void appendKeyValue(StringBuilder buf, String key,

private String mdcSubst(String v, Map<String, String> mdc) {
if (mdc != null && v != null && v.contains("@{")) {
Pattern p = Pattern.compile("\\@\\{([^}]*)\\}");
Matcher m = p.matcher(v);
Matcher m = MDC_VAR_PATTERN.matcher(v);
StringBuffer sb = new StringBuffer(v.length());
while (m.find()) {
String val = mdc.get(m.group(1));
Expand Down

0 comments on commit 3e07aaf

Please sign in to comment.