使用Logger时会出现错误 - &quot'考虑定义类型'org.slf4j.logger'在您的配置中。

发布于 2025-02-06 17:28:11 字数 545 浏览 0 评论 0原文

我的代码: -

导入org.slf4j.logger;

导入org.slf4j.loggerfactory;

logger logger = loggerfactory.getLogger(myService.Class);

logger.info(“”);

我遇到了这个错误 - >

错误启动ApplicationContext。要显示条件报告报告,请启用“调试”重新运行您的应用程序。 2022-06-13 14:38:42.998错误12884 --- [main] Osbdloggingfailureanalysiseporter:


应用程序无法启动


说明:

com.myapp.app.service.service.service.myservice中的构造函数2的参数需要'org.slf4j的bean of type'org.slf4j。找不到的记录仪。

操作:

考虑在您的配置中定义“ org.slf4j.logger”类型的豆。

使用出口代码1完成过程1

My code:-

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

Logger logger = LoggerFactory.getLogger(MyService.class);

logger.info("");

i am getting this error ->

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-06-13 14:38:42.998 ERROR 12884 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Parameter 2 of constructor in com.myapp.app.service.MyService required a bean of type 'org.slf4j.Logger' that could not be found.

Action:

Consider defining a bean of type 'org.slf4j.Logger' in your configuration.

Process finished with exit code 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

还在原地等你 2025-02-13 17:28:11

您是否将某种记录器添加为依赖性?

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.6.1</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.6.1</version>
</dependency>

还是您可以向我们展示您的记录依赖性?

另外,还有一些可供伐木的教程:

Do you have some kind of a logger added as a dependency?

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.6.1</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.6.1</version>
</dependency>

Or can you show us your logger dependencies?

Also there are good tutorials for logging:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文