Could Not Find Value For Key Log4j.appender.error
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up log4j appender issue - unable to print debug, error levels up vote 2 down vote favorite I am using a log4j for logging. This is how my log4j.properties looks like # Root logger option log4j.rootLogger=info, debug, error file # Direct log messages to a log file log4j.appender.file=org.apache.log4j.RollingFileAppender #Redirect to Tomcat logs folder #log4j.appender.file.File=${catalina.home}/logs/logging.log log4j.appender.file.File=C:\\Users\\raj_sanpui\\Desktop\\Automation\\test.log log4j.appender.file.MaxFileSize=10MB log4j.appender.file.MaxBackupIndex=10 log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n Each of my Java files constructor has this call: public class IMGOperations { private org.apache.log4j.Logger log; private String hostname; private String sysid; private String dicomfilepath; public IMGOperations(String hostname, String sysid, String dicomfilepath) { this.hostname=hostname; this.sysid=sysid; this.dicomfilepath=dicomfilepath; PropertyConfigurator.configure(mainConfig.LOG4JCONFPATH); log = Logger.getLogger(mainConfig.class); } I am getting this error on running my Java program: log4j:ERROR Could not find value for key log4j.appender.debug log4j:ERROR Could not instantiate appender named "debug". log4j:ERROR Could not find value for key log4j.appender.error file log4j:ERROR Could not instantiate appender named "error file". log4j:ERROR Could not find value for key log4j.appender.debug I am basically a C/C++ folk, who knows Core Java, and pretty much a noob in this stuff. So please pardon me, if you find it too basic. java log4j share|improve this question asked Jan 19 '15 at 10:14 kingsmasher1 3,100144799 add a comment| 2 Answers 2 active oldest votes up vote 6 down vote accepted The problem is in your second line, it should be: # Root logger option log4j.rootLogger=INFO, stdout, file This means you will log
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags http://stackoverflow.com/questions/28022232/log4j-appender-issue-unable-to-print-debug-error-levels Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ERROR Could not find value for key log4j.appender.error during deploying on http://stackoverflow.com/questions/32760493/error-could-not-find-value-for-key-log4j-appender-error-during-deploying-on-tomc tomcat up vote 1 down vote favorite my code is working fine if i right click on server and run as run on server , but when i try to deploy it on tomcat and try to run it it is giving me below error log4j.properties file: log4j.logger.Controller = INFO,error,stdout log4j.logger.Client = INFO,error,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: log4j:ERROR Could not find value for key log4j.appender.error log4j:ERROR Could not instantiate appender named "error". log4j:ERROR Could not find value for key log4j.appender.error log4j:ERROR Could not instantiate appender named "error". 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#noconfig for more info. pom.xml :
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta http://stackoverflow.com/questions/33097315/error-could-not-find-value-for-key-log4j-appender-error Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack https://coderanch.com/t/525530/vc/error-log-properties Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping could not each other. Join them; it only takes a minute: Sign up ERROR Could not find value for key log4j.appender.error up vote 1 down vote favorite my 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 could not find 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#noconfig for more info. 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"); java spring logging log4j share|improve this question edited Oct 13 '15 at 10:19 asked Oct 13 '15 at 8:05 Labeo 85421033 is log4j.properties is in your classpath –geekyprathmesh Oct 13 '15 at 8:08 it is in src/main/resources folder –Labeo Oct 13 '15 at 8:10 please try after moving it to src/main folder –geekyprathmesh Oct 13 '15 at 8:17 not working same eror –Labeo Oct 13 '15 at 8:24 please try one more :) , try to move in scr/main/java , i think your log4j is not detecting, so it is calling other one –geekyprathmesh Oct 13 '15 at 8
This Site Careers Other all forums Forum: IDEs, Version Control and other tools error in log4j.properties sulthan mathina Greenhorn Posts: 6 posted 5 years ago log4j.properties # The following properties set the logging levels and log appender. The # log4j.rootCategory variable defines the default log level and one or more # appenders. For the console, use 'S'. For the daily rolling file, use 'R'. # For an HTML formatted log, use 'H'. log4j.rootCategory=DEBUG, S,R log4j.logger.com.bgs.entity=INFO # The following properties configure the Daily Rolling File appender. log4j.appender.R = org.apache.log4j.DailyRollingFileAppender log4j.appender.R.File = c:/excel/sm7.log log4j.appender.R.Append = true log4j.appender.R.DatePattern = '.'yyy-MM-dd log4j.appender.R.layout = org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss},[%p],%c{1},%M,%m%n In java:Main.java public class Main { static Logger logger = Logger.getLogger("Main"); Error in console , while executing java file log4j:WARN No appenders could be found for logger (Main). log4j:WARN Please initialize the log4j system properly. sri ramvaithiyanathan Ranch Hand Posts: 109 posted 5 years ago sulthan mathina wrote:log4j.properties log4j.rootCategory=DEBUG, S,R check whether you commented the above mentioned lines. and remove the S.your code should be like this log4j.rootCategory=DEBUG,R Because you haven't used S in your log4j.properties file. If you use S you will get the following error log4j:ERROR Could not find value for key log4j.appender.S log4j:ERROR Could not instantiate appender named "S". In your java class use this way static Logger logger = Logger.getLogger("Main.class"); instead of static Logger logger = Logger.getLogger("Main"); Regards, Sriram.V For java examples,ebooks,interview questions,visit this blog http://periodicupdates.blogspot.com/ Post Reply Bookmark Topic Watch Topic New Topic Similar Threads Need help with log4j logging tool to log into database log4j:WARN No appenders could be found for logger (log4jexample.LogExample). log4j does not works because it says there is no appender what is log4j.properties , why we need this. how to create this in java project using eclipse IDE log4j:WARN Please initialize the log4j system properly All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter Contact Us | advertise | mobile view | Powered by JForum | Copyright © 1998-2016 Paul Wheaton