java 错误找不到键 log4j.appender.error 的值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33097315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR Could not find value for key log4j.appender.error
提问by Labeo
my log4j.properties:
我的 log4j.properties:
log4j.logger.Controller = INFO,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
error trace:
错误跟踪:
log4j:ERROR Could not find value for key log4j.appender.error log4j:ERROR Could not instantiate appender named "error". Oct 13, 2015 1:32:50 PM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfigfor more info.
log4j:ERROR 找不到 key log4j.appender.error 的值 log4j:ERROR 无法实例化名为“error”的 appender。2015 年 10 月 13 日下午 1:32:50 org.apache.catalina.core.ApplicationContext 日志信息:初始化 Spring 根 WebApplicationContext log4j:WARN 找不到记录器 (org.springframework.web.context.ContextLoader) 的附加程序。log4j:WARN 请正确初始化 log4j 系统。log4j:WARN 有关更多信息,请参阅http://logging.apache.org/log4j/1.2/faq.html#noconfig。
where is error appender in code i dont get it
代码中的错误附加器在哪里我不明白
Update:
更新:
Writing code how i am using log
编写代码我如何使用日志
final static Logger logger = Logger.getLogger(Controller.class);
logger.info("200 OK");
logger.error("Incorrect json format");
回答by Lucky
Try this in your log4j.properties file,
在你的 log4j.properties 文件中试试这个,
# Set root logger level to INFO and its only appender to stdout
log4j.rootLogger=INFO, stdout
# stdout is set to be a ConsoleAppender.
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# stdout uses PatternLayout.
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c:%L - %m%n
See more in Apache log4j 2.x documentation guide.