aspose file tools*
The moose likes Other Open Source Projects and the fly likes log4j error message - please send solutions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j error message - please send solutions" Watch "log4j error message - please send solutions" New topic
Author

log4j error message - please send solutions

rajareddy annavaarm
Ranch Hand

Joined: Mar 15, 2007
Posts: 96
a)log4j:WARN No appenders could be found for logger (com.sns.al.AppLauncher).
log4j:WARN Please initialize the log4j system properly.

b)log4j:ERROR Attempted to append to closed appender named [A-LRI]

this is my log4j configuration file

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{ABSOLUTE} %5p %c{1}:%L - %m%n

#this is mandatory, DO NOT CHANGE
log4j.categoryFactory=com.sns.base.util.logging.LoggerFactory
log4j.rootCategory=DEBUG,A-LRI

#com.sns.member must be renamed to the package that you are working on
#e.g. com.trade.ita, com.sns.iscm.ifx.ita.common,
#A-LRI MUST-BE-CHANGED
#e.g. A-ITA, A-COMMON,
log4j.category.com.sns.legal.lri=DEBUG, A-LRI
log4j.category.com.sns.govt.lri=DEBUG, A-LRI
log4j.category.com.sns.govt.lri.alrrs.landlots.dao=DEBUG, A-LRI
log4j.category.com.sns.govt.lri.alrrs.gazettes.dao=DEBUG, A-LRI
log4j.category.log4jEffeciency=ERROR


#The LRIA was done so that logger log4j is backward compatable

#this is mandatory, DO NOT CHANGE
#Edit only A-LRI
log4j.appender.A-LRI=org.apache.log4j.RollingFileAppender
log4j.appender.A-LRI.layout=org.apache.log4j.PatternLayout
#log4j.appender.A-LRI.layout.ConversionPattern=%d [%c{3}] %-5p - %m%n
#log4j.appender.A-LRI.layout.ConversionPattern=%d{ISO8601} %-5p %c{3}: %L - %m%n
log4j.appender.A-LRI.layout.ConversionPattern=%d{ISO8601} %-5p %c{3}: %L - %m%n
#Edit A-LRI
#the full path MUST-BE-CHANGED
log4j.appender.A-LRI.File=/sns/legal/lri/rel1_0/logs/lri.log

#this is mandatory, DO NOT CHANGE
#Edit only A-LRI
#set the maximum size for the log file, after which will be backup
log4j.appender.A-LRI.MaxFileSize=5000KB

#if the specified log file is 'lri.log', once the MaxFileSize is reached
#it will be backed up to 'lri.log.1' and so forth till the MaxBackupIndex
log4j.appender.A-LRI.MaxBackupIndex=8

#When your program is going to trial or production, the mode has to be changed to INFO.
#This is to turn off the Debug messages.
[ March 16, 2007: Message edited by: Ulf Dittmer ]
Dirk Lombard
Greenhorn

Joined: Jul 27, 2005
Posts: 18
What version of log4j are you using? Do you use a PropertyConfigurator.configure("your properties file) to get your set your properties?


SCJP 1.4<br />SCWCD 1.4
rajareddy annavaarm
Ranch Hand

Joined: Mar 15, 2007
Posts: 96
I am using log4j 1.2.8 version.I am using properties file .
Sirish Kumar Gongal Reddy
Ranch Hand

Joined: Oct 25, 2004
Posts: 109
Hello,

where you are loading and initializing your log4j.properties file?

First you need to load your property file and then you need to call PropertyConfigurator.configure(prop); do something like,
package com.examples;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class LogManager{

static
{
// initializes the log4j stuff
try{
Properties prop = new Properties();
prop.load(new FileInputStream(new File("C:/Documents and Settings/mkhajamiya/workspace/Examples/src/log4j.properties")));
PropertyConfigurator.configure(prop);
}catch(Exception ex){
ex.printStackTrace();
}
}
public Logger getLogger(Class arg0){
return Logger.getLogger(arg0);
}

}

then use above class where ever you need to do logging,do something like..

LogManager manager = new LogManager();
Logger log = manager.getLogger(YOURCLASS.class);
log.info("you are done with log4j");
log.error("Opps...error again");

Hope it will help you. Thanks!

/Sirish
Frank Wiesen
Greenhorn

Joined: Aug 02, 2007
Posts: 1
Hi there,

if you create a property file "log4j.properties" inside the classpath (e.g.
inside the classes root directory of your project), Log4J will find and load the file automatically.
Enable logging to see, how it initializes and which file it finds/loads:
Add "-Dlog4j.debug=1" to the system properties of your JVM.

But I expect, the property "log4j.categoryFactory=..." will have no affect (except log4j tells you, it replaces the default category factory, BUT IT WON'T, because the code inside the "PropertyConfigurator" finally replacing the factory at the "Hierarchy" class was disabled with Log4J 1.13 and the method "setCategoryFactory(...)" to do so even removed from "Hierarchy" with 1.2. So it's even not possible to replace it manually anymore. With 1.3 in January there was code checked in defining a new "setLoggerFactory(...)" at Hirarchy. But there was no further alpha release of 1.3 this year, so we still have to wait, if we want to replace the default Logger/CategoryFactory...

Best Regards,
Frank
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4j error message - please send solutions
 
Similar Threads
Strange behaviour 'DailyRollingFileAppender', two process one log4j configuration file
Why do I get "log4j:WARN No appenders could be found for logger" message on server st
Struck thread and deadlock while getting connection
How to separate Console and / or File appenders in Log4J?
question on log4j and eclipse