• Post Reply Bookmark Topic Watch Topic
  • New Topic

Log4J No appenders  RSS feed

 
Sylvia H Charbonneau
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Day All!
Been trying to customize Log4J, and I can't seem to solve the following problem...and I just can't seem to find the documents to help me out. Hopefully, one of you brilliant folks can give me a hand !
Here is the error I receive:
log4j:WARN No appenders could be found for logger (com.javaexchange.dbConnBroker).
log4j:WARN Please initialize the log4j system properly.
----[ The code that causes it:
public class DbConnBroker implements Runnable
{
//-- Setup Class Level Logging Variables
String className = "DbConnBroker";
String Log4jConfig = "/" + className + "_log4j.lcf";
static Logger log4jLog = Logger.getLogger("com.javaexchange.dbConnBroker");
static long configFileWatchDelay = 100; //-- in Milliseconds


public DbConnBroker (String s, String s1) throws IOException
{
PropertyConfigurator.configureAndWatch(Log4jConfig, configFileWatchDelay);
}....
}
-----------------------------------------------------------------------
----[ The properties file, DbConnBroker_log4j.lcf
log4j.rootLogger=debug, Appender2
# How File is created/appended to
log4j.appender.Appender2=org.apache.log4j.RollingFileAppender
log4j.appender.Appender2.Append=false
# File Name is located in C:/NHP_Logs/DbConnectionBroker_log4j.log
log4j.appender.Appender2.File=/NHP_Logs/DbConnectionBroker_log4j.log
# Max Size of File
log4j.appender.Appender2.MaxFileSize=100KB
# Keep 10 backup files
log4j.appender.Appender2.MaxBackupIndex=10
# Pattern to output the caller's file name and line number.
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
-------------------------------------------------------------------------
As far as I can tell from the documentation on the jakarta site, this is supposed to work. Any ideas ?
Sylvia
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my config:


now you are able to call:

/Rene
 
Sylvia H Charbonneau
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
I also had to change the PropertyConfigurator.configureAndWatch method to just PropertyConfigurator.configure
Sylvia
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!