错误 StatusLogger 无法识别的格式说明符
Error StatusLogger Unrecognized Format specifier
Spring 4.3.30+hibernate 5 应用程序。 pom.xml 具有所有 log4j2 依赖项。
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>${log4j2.version}</version>
</dependency>
甚至添加了log4j2.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="TRACE">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%p [%t] %c{1}.%M(%L) | %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
我遇到的错误:
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.
我还遗漏了什么,因为即使我的模式不包含默认布局,我仍然遇到上述错误?
在迁移到 log4j2.Din 之前我正在使用 log4j 不打算迁移到 log4j2 但是因为我必须升级 spring 和休眠我开始得到错误 StatusLogger 没有找到 Log4j2 配置文件。那是我决定迁移到 log4j2 的时候。
首先,让我们列出您的依赖项及其作用:
- log4j-jcl 为 Apache Commons Logging 提供了一个实现,以将这些日志记录调用路由到 Log4j 2。
- log4j-core 是 Log4j 2 实现。
- log4j-slf4j-impl 使用 SLF4J API 将日志记录调用路由到 Log4j 2。
- log4j-api 是 Log4j 2 API.
- log4j-1.2-api 将使用 log4j 1.x 进行的日志记录调用路由到 Log4j 2.
- log4j-to-slf4j 将日志记录调用从 Log4j 2 API 路由到 SLF4J。
如果描述不清楚,第 6 项就会有问题。首先,您现在有 Log4j 2 API 的 2 个实现 - log4j-core 和 log4j-to-slf4j。如果 log4j-to-slf4j 是“获胜者”,那么您最终将无法进行日志记录,因为调用会在 Log4j 和 SLF4J 之间反弹并再次返回。
但是,如果这些在 pom 的 dependencyManagement 部分中,那将是另一回事,因为所做的只是声明您要使用的 jar 版本。
至于您看到的错误,这是因为由于某种原因没有加载 Log4j 的核心插件。如果您将所有内容都隐藏到一个 jar 中并且不包含 Log4j 的 Log4jPlugins.dat 文件,就会发生这种情况。
Spring 4.3.30+hibernate 5 应用程序。 pom.xml 具有所有 log4j2 依赖项。
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>${log4j2.version}</version>
</dependency>
甚至添加了log4j2.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="TRACE">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%p [%t] %c{1}.%M(%L) | %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
我遇到的错误:
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.
我还遗漏了什么,因为即使我的模式不包含默认布局,我仍然遇到上述错误? 在迁移到 log4j2.Din 之前我正在使用 log4j 不打算迁移到 log4j2 但是因为我必须升级 spring 和休眠我开始得到错误 StatusLogger 没有找到 Log4j2 配置文件。那是我决定迁移到 log4j2 的时候。
首先,让我们列出您的依赖项及其作用:
- log4j-jcl 为 Apache Commons Logging 提供了一个实现,以将这些日志记录调用路由到 Log4j 2。
- log4j-core 是 Log4j 2 实现。
- log4j-slf4j-impl 使用 SLF4J API 将日志记录调用路由到 Log4j 2。
- log4j-api 是 Log4j 2 API.
- log4j-1.2-api 将使用 log4j 1.x 进行的日志记录调用路由到 Log4j 2.
- log4j-to-slf4j 将日志记录调用从 Log4j 2 API 路由到 SLF4J。
如果描述不清楚,第 6 项就会有问题。首先,您现在有 Log4j 2 API 的 2 个实现 - log4j-core 和 log4j-to-slf4j。如果 log4j-to-slf4j 是“获胜者”,那么您最终将无法进行日志记录,因为调用会在 Log4j 和 SLF4J 之间反弹并再次返回。
但是,如果这些在 pom 的 dependencyManagement 部分中,那将是另一回事,因为所做的只是声明您要使用的 jar 版本。
至于您看到的错误,这是因为由于某种原因没有加载 Log4j 的核心插件。如果您将所有内容都隐藏到一个 jar 中并且不包含 Log4j 的 Log4jPlugins.dat 文件,就会发生这种情况。