• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

log4j error message - please send solutions

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What version of log4j are you using? Do you use a PropertyConfigurator.configure("your properties file) to get your set your properties?
 
rajareddy annavaarm
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using log4j 1.2.8 version.I am using properties file .
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic