Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug of ERROR StatusLogger Unrecognized format specifier when … #218

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

ASanny
Copy link
Contributor

@ASanny ASanny commented Jan 11, 2024

When starting with a jar package, the following error log will appear:

WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.

After analysis, in the Maven Shade Plugin, if <minimizeJar> is set to true. The final generated jar file will be minimized. During the minimization process, a total of 163 classes related to log4j2 will be removed:

org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$White
org.apache.logging.log4j.core.pattern.MethodLocationPatternConverter
org.apache.logging.log4j.core.appender.FailoverAppender
org.apache.logging.log4j.core.lookup.MapLookup
org.apache.logging.log4j.core.appender.RandomAccessFileAppender
org.apache.logging.log4j.core.lookup.LowerLookup
org.apache.logging.log4j.core.filter.BurstFilter
org.apache.logging.log4j.core.pattern.MdcPatternConverter
org.apache.logging.log4j.core.filter.LevelRangeFilter
org.apache.logging.log4j.core.appender.FileAppender
org.apache.logging.log4j.core.pattern.DatePatternConverter
org.apache.logging.log4j.core.lookup.DateLookup
org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicy
org.apache.logging.log4j.core.net.SocketOptions
org.apache.logging.log4j.core.script.Script
org.apache.logging.log4j.core.layout.PatternMatch
org.apache.logging.log4j.core.appender.nosql.NoSqlAppender
org.apache.logging.log4j.core.appender.rolling.action.ScriptCondition
org.apache.logging.log4j.core.appender.db.jdbc.DataSourceConnectionSource
org.apache.logging.log4j.core.pattern.FileDatePatternConverter
org.apache.logging.log4j.core.appender.rolling.DirectWriteRolloverStrategy
org.apache.logging.log4j.core.pattern.ThreadIdPatternConverter
org.apache.logging.log4j.core.appender.rolling.action.PosixViewAttributeAction
org.apache.logging.log4j.core.appender.routing.Routes
org.apache.logging.log4j.core.layout.SyslogLayout
org.apache.logging.log4j.core.lookup.SystemPropertiesLookup
org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy
org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup
org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender
org.apache.logging.log4j.core.lookup.JndiLookup
org.apache.logging.log4j.core.appender.ScriptAppenderSelector
org.apache.logging.log4j.core.appender.mom.jeromq.JeroMqAppender
org.apache.logging.log4j.core.pattern.EndOfBatchPatternConverter
org.apache.logging.log4j.core.appender.rolling.action.IfAll
org.apache.logging.log4j.core.filter.DenyAllFilter
org.apache.logging.log4j.core.pattern.RepeatPatternConverter
org.apache.logging.log4j.core.appender.db.ColumnMapping
org.apache.logging.log4j.core.appender.rolling.action.PathSortByModificationTime
org.apache.logging.log4j.core.appender.WriterAppender
org.apache.logging.log4j.core.filter.ScriptFilter
org.apache.logging.log4j.core.layout.GelfLayout
org.apache.logging.log4j.core.filter.MapFilter
org.apache.logging.log4j.core.pattern.LevelPatternConverter
org.apache.logging.log4j.core.config.AppendersPlugin
org.apache.logging.log4j.core.layout.HtmlLayout
org.apache.logging.log4j.core.pattern.RootThrowablePatternConverter
org.apache.logging.log4j.core.layout.YamlLayout
org.apache.logging.log4j.core.appender.HttpAppender
org.apache.logging.log4j.core.net.SocketAddress
org.apache.logging.log4j.core.pattern.UuidPatternConverter
org.apache.logging.log4j.core.pattern.LoggerPatternConverter
org.apache.logging.log4j.core.pattern.ProcessIdPatternConverter
org.apache.logging.log4j.core.appender.NullAppender
org.apache.logging.log4j.core.layout.LoggerFields
org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy
org.apache.logging.log4j.core.pattern.FileLocationPatternConverter
org.apache.logging.log4j.core.appender.rolling.NoOpTriggeringPolicy
org.apache.logging.log4j.core.filter.StringMatchFilter
org.apache.logging.log4j.core.lookup.MainMapLookup
org.apache.logging.log4j.core.pattern.MessagePatternConverter
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Cyan
org.apache.logging.log4j.core.util.KeyValuePair
org.apache.logging.log4j.core.config.ScriptsPlugin
org.apache.logging.log4j.core.config.arbiters.ScriptArbiter
org.apache.logging.log4j.core.net.SocketPerformancePreferences
org.apache.logging.log4j.core.lookup.Log4jLookup
org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileCount
org.apache.logging.log4j.core.config.arbiters.SystemPropertyArbiter
org.apache.logging.log4j.core.appender.rolling.action.DeleteAction
org.apache.logging.log4j.core.filter.DynamicThresholdFilter
org.apache.logging.log4j.core.pattern.MapPatternConverter
org.apache.logging.log4j.core.config.json.JsonConfigurationFactory
org.apache.logging.log4j.core.appender.rewrite.PropertiesRewritePolicy
org.apache.logging.log4j.core.config.arbiters.ClassArbiter
org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory
org.apache.logging.log4j.core.layout.JsonLayout
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Red
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Magenta
org.apache.logging.log4j.core.layout.SerializedLayout
org.apache.logging.log4j.core.net.MulticastDnsAdvertiser
org.apache.logging.log4j.core.pattern.NdcPatternConverter
org.apache.logging.log4j.core.appender.FailoversPlugin
org.apache.logging.log4j.core.filter.MarkerFilter
org.apache.logging.log4j.core.appender.mom.JmsAppender
org.apache.logging.log4j.core.appender.rewrite.RewriteAppender
org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender
org.apache.logging.log4j.core.lookup.UpperLookup
org.apache.logging.log4j.core.pattern.IntegerPatternConverter
org.apache.logging.log4j.core.layout.CsvLogEventLayout
org.apache.logging.log4j.core.layout.ScriptPatternSelector
org.apache.logging.log4j.core.layout.MarkerPatternSelector
org.apache.logging.log4j.core.pattern.LoggerFqcnPatternConverter
org.apache.logging.log4j.core.pattern.EqualsIgnoreCaseReplacementConverter
org.apache.logging.log4j.core.pattern.HighlightConverter
org.apache.logging.log4j.core.pattern.EqualsReplacementConverter
org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy
org.apache.logging.log4j.core.filter.TimeFilter
org.apache.logging.log4j.core.appender.routing.Route
org.apache.logging.log4j.core.appender.db.jdbc.ColumnConfig
org.apache.logging.log4j.core.appender.rolling.action.IfFileName
org.apache.logging.log4j.core.lookup.StructuredDataLookup
org.apache.logging.log4j.core.lookup.ResourceBundleLookup
org.apache.logging.log4j.core.pattern.MaxLengthConverter
org.apache.logging.log4j.core.appender.SocketAppender
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Blue
org.apache.logging.log4j.core.pattern.ThreadPriorityPatternConverter
org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy
org.apache.logging.log4j.core.appender.OutputStreamAppender
org.apache.logging.log4j.core.lookup.EventLookup
org.apache.logging.log4j.core.config.HttpWatcher
org.apache.logging.log4j.core.appender.mom.kafka.KafkaAppender
org.apache.logging.log4j.core.pattern.EncodingPatternConverter
org.apache.logging.log4j.core.appender.AppenderSet
org.apache.logging.log4j.core.pattern.ThreadNamePatternConverter
org.apache.logging.log4j.core.async.DisruptorBlockingQueueFactory
org.apache.logging.log4j.core.appender.rolling.action.IfNot
org.apache.logging.log4j.core.filter.LevelMatchFilter
org.apache.logging.log4j.core.lookup.ContextMapLookup
org.apache.logging.log4j.core.async.JCToolsBlockingQueueFactory
org.apache.logging.log4j.core.pattern.MarkerSimpleNamePatternConverter
org.apache.logging.log4j.core.pattern.StyleConverter
org.apache.logging.log4j.core.filter.ThreadContextMapFilter
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Yellow
org.apache.logging.log4j.core.pattern.RelativeTimePatternConverter
org.apache.logging.log4j.core.lookup.JavaLookup
org.apache.logging.log4j.core.pattern.VariablesNotEmptyReplacementConverter
org.apache.logging.log4j.core.appender.SmtpAppender
org.apache.logging.log4j.core.filter.StructuredDataFilter
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Black
org.apache.logging.log4j.core.pattern.ClassNamePatternConverter
org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource
org.apache.logging.log4j.core.layout.CsvParameterLayout
org.apache.logging.log4j.core.appender.RollingFileAppender
org.apache.logging.log4j.core.config.LoggersPlugin
org.apache.logging.log4j.core.layout.MessageLayout
org.apache.logging.log4j.core.lookup.MarkerLookup
org.apache.logging.log4j.core.async.LinkedTransferQueueFactory
org.apache.logging.log4j.core.appender.db.jdbc.DriverManagerConnectionSource
org.apache.logging.log4j.core.filter.RegexFilter
org.apache.logging.log4j.core.appender.MemoryMappedFileAppender
org.apache.logging.log4j.core.layout.LevelPatternSelector
org.apache.logging.log4j.core.appender.rewrite.LoggerNameLevelRewritePolicy
org.apache.logging.log4j.core.appender.rewrite.MapRewritePolicy
org.apache.logging.log4j.core.pattern.LineLocationPatternConverter
org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy
org.apache.logging.log4j.core.pattern.MarkerPatternConverter
org.apache.logging.log4j.core.filter.NoMarkerFilter
org.apache.logging.log4j.core.lookup.EnvironmentLookup
org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileSize
org.apache.logging.log4j.core.appender.rolling.action.IfLastModified
org.apache.logging.log4j.core.layout.XmlLayout
org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory
org.apache.logging.log4j.core.appender.routing.RoutingAppender
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Green
org.apache.logging.log4j.core.pattern.LineSeparatorPatternConverter
org.apache.logging.log4j.core.appender.rolling.action.IfAny
org.apache.logging.log4j.core.appender.CountingNoOpAppender
org.apache.logging.log4j.core.layout.Rfc5424Layout
org.apache.logging.log4j.core.pattern.RegexReplacementConverter
org.apache.logging.log4j.core.pattern.SequenceNumberPatternConverter
org.apache.logging.log4j.core.appender.SyslogAppender
org.apache.logging.log4j.core.appender.routing.IdlePurgePolicy
org.apache.logging.log4j.core.pattern.FullLocationPatternConverter

As a result, the pattern parser org.apache.logging.log4j.core.pattern.PatternParser#createConverter obtains the corresponding converter based on converterId to be null, resulting in the above error. The specific locations are as follows:

private PatternConverter createConverter(final String converterId, final StringBuilder currentLiteral,
        final Map<String, Class<PatternConverter>> rules, final List<String> options, final boolean disableAnsi,
        final boolean noConsoleNoAnsi) {
    ......

    // Error message is printed here
    if (converterClass == null) {
        LOGGER.error("Unrecognized format specifier [" + converterId + ']');
        return null;
    }
}

The above bug can be fixed by including log4j related files in the final jar package:

<filter>
  <artifact>org.apache.logging.log4j:*</artifact>
  <includes>
    <include>**</include>
  </includes>
</filter>

@joelsdc
Copy link

joelsdc commented Jan 12, 2024

Hey @ASanny

Any change you can make available for download a .jar of your PR so I can test it? I'm running into some issues that I cannot fix without logs :-(

@ASanny
Copy link
Contributor Author

ASanny commented Jan 12, 2024

Hey @ASanny

Any change you can make available for download a .jar of your PR so I can test it? I'm running into some issues that I cannot fix without logs :-(

Hey @ASanny

Any change you can make available for download a .jar of your PR so I can test it? I'm running into some issues that I cannot fix without logs :-(

joelsdc

Hi @joelsdc

You can find a working jar in the repository below. I put a packaged jar under Releases of the repository not long ago, the URL is: https://github.com/ASanny/zipkin-dependencies

@joelsdc
Copy link

joelsdc commented Jan 12, 2024

Amazing, thank you! I'm going to test this now and let you know.

@joelsdc
Copy link

joelsdc commented Jan 12, 2024

Confirmed, your patch fixes the logging! Thank you.

I hope it's merged soon.

@joelsdc
Copy link

joelsdc commented Jan 16, 2024

@codefromthecrypt tagging you here in case you can review and merge this.

@codefromthecrypt
Copy link
Member

sorry I was accidentally not watching.. looking now ;)

Copy link
Member

@shakuzen shakuzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't given it a spin but the explanation and configuration make sense to me.

@@ -80,6 +80,12 @@
<minimizeJar>true</minimizeJar>
<filters>
<!-- Prevent minification from excluding classes looked up by name -->
<filter>
<artifact>org.apache.logging.log4j:*</artifact>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two blocks down it looks like we have log4j:log4j. At some point I guess we switched dependencies and updating this part of the build was missed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep must have been it!

@codefromthecrypt codefromthecrypt merged commit bd86ec7 into openzipkin:master Jan 17, 2024
5 checks passed
@codefromthecrypt
Copy link
Member

3.1.1 on the way. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants