春季:"SimpleLogger似乎不知道位置".例外 [英] Spring: "SimpleLogger does not seem to be location aware" exception

查看:84
本文介绍了春季:"SimpleLogger似乎不知道位置".例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在第一行代码的Spring应用程序中遇到异常:

ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");

我将commons-logging-1.1.1.jar配置为项目库.

这是堆栈跟踪:

java.lang.UnsupportedOperationException:记录器[org.slf4j.impl.SimpleLogger(org.springframework.context.support.ClassPathXmlApplicationContext)]似乎不知道位置.

在org.apache.log4j.Category.log(Category.java:347) 在org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:199) 在org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:456) 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:394) 在org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) 在org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)

解决方案

好像您正在同时使用多个日志记录框架.该错误似乎是SLF4J和Log4J配置之间发生冲突的征兆.

看看这篇文章:
http://www.qos.ch/pipermail/slf4j- user/2010-February/000892.html
其中,

代码日志(字符串FQCN,优先级p, 对象msg,Throwable t)方法抛出 异常,因为调用者 期望位置感知日志记录,但是 实际的记录器实现不是 能够传递位置 意识".

没有更多信息,我的最佳猜测是,您引用了诸如slf4j-nop-1.6.1.jar之类的slf4j jar或其他通过指向Logger类的非操作实现而关闭日志的内容. /p>

找到罪魁祸首并将其删除(或将其替换为slf4j-log4j版本).

您正在使用Maven吗?

如果是,请打开pom文件的依赖关系图,并使用名称中的 slf4j 搜索所有依赖项.删除一个看起来像NOOP jar的容器.

I'm getting an exception in a Spring app on my first line of code:

ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");

I have commons-logging-1.1.1.jar configured as a project library.

Here is the stack trace:

java.lang.UnsupportedOperationException: The logger [org.slf4j.impl.SimpleLogger(org.springframework.context.support.ClassPathXmlApplicationContext)] does not seem to be location aware.

at org.apache.log4j.Category.log(Category.java:347) at org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:199) at org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:456) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:394) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)

解决方案

Looks like you are using multiple logging frameworks at the same time. This error seems to be a symptom of a clash between your SLF4J and Log4J configurations.

Take a look at this post:
http://www.qos.ch/pipermail/slf4j-user/2010-February/000892.html
which states,

The code log(String FQCN, Priority p, Object msg, Throwable t) method throws an exception because the caller expects location aware logging but the actual logger implementation is not capable of delivering "location awareness".

Without more information, my best guess is that you have a reference to an slf4j jar like slf4j-nop-1.6.1.jar or something else that's turning off logging by pointing to Non-Operational implementation of the Logger class.

Find the culprit and delete it (or replace it with the slf4j-log4j version).

Are you using Maven?

If so, open the dependency graph of your pom file and search for all dependencies with slf4j in their name. Delete the one that looks like a NOOP jar.

这篇关于春季:"SimpleLogger似乎不知道位置".例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆