diff --git a/src/main/java/org/jboss/logmanager/formatters/FormatStringParser.java b/src/main/java/org/jboss/logmanager/formatters/FormatStringParser.java index 31ec3e06..b2d956b5 100644 --- a/src/main/java/org/jboss/logmanager/formatters/FormatStringParser.java +++ b/src/main/java/org/jboss/logmanager/formatters/FormatStringParser.java @@ -107,7 +107,7 @@ public static FormatStep[] getSteps(final String formatString, ColorMap colors) break; } case 'h': { - stepList.add(Formatters.hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, argument == null ? "1" : argument)); + stepList.add(Formatters.hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, false)); break; } case 'H': { diff --git a/src/main/java/org/jboss/logmanager/formatters/Formatters.java b/src/main/java/org/jboss/logmanager/formatters/Formatters.java index b21083de..0f02ebea 100644 --- a/src/main/java/org/jboss/logmanager/formatters/Formatters.java +++ b/src/main/java/org/jboss/logmanager/formatters/Formatters.java @@ -471,7 +471,13 @@ public void renderRaw(final StringBuilder builder, final ExtLogRecord record) { * @return the format step */ public static FormatStep hostnameFormatStep(final boolean leftJustify, final int minimumWidth, final boolean truncateBeginning, final int maximumWidth, final boolean qualified) { - return hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, qualified ? null : "1"); + return qualified ? hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, null) : new SegmentedFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, null) { + public String getSegmentedSubject(final ExtLogRecord record) { + final String hostName = record.getHostName(); + final int idx = hostName.indexOf('.'); + return idx == -1 ? hostName :hostName.substring(0, idx); + } + }; } /**