You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "S.Kannan" <te...@yahoo.co.in> on 2010/01/27 12:07:40 UTC
ClassCirculatoryError
The following is our own LogManager which does not extends the LogManager of
log4j
public class LogManager {
String className;
Logger objLog;
static {
InputStream logProps = LogManager.class.getClassLoader()
.getResourceAsStream(ABCConstants.LOGFILE);
try {
Properties prop = new Properties();
prop.load(logProps);
PropertyConfigurator.configure(prop);
} catch (Exception e) {
System.out.println("error in LogManager" + e.getMessage());
}
}
public void logMessage(String strLevel, String Message) {
if (strLevel.equals(ABCConstants.DEBUG)) {
objLog.log(ABCLevel.DEBUG, Message);
} else if (strLevel.equals(ABCConstants.INFO)) {
objLog.log(ABCLevel.INFO, Message);
} else if (strLevel.equals(ABCConstants.WARN)) {
objLog.log(ABCLevel.WARN, Message);
} else if (strLevel.equals(ABCConstants.ERROR)) {
objLog.log(ABCLevel.ERROR, Message);
} else if (strLevel.equals(ABCConstants.FATAL)) {
objLog.log(ABCLevel.FATAL, Message);
} else if (strLevel.equals(ABCConstants.DASH)) {
objLog.log(ABCLevel.DASH, Message);
}
/*
* Default is o log at DEBUG level
*/
else {
objLog.log(ABCLevel.DEBUG, Message);
}
}
}
The following is the custom level
import org.apache.log4j.Level;
public class ABCLevel extends Level {
//Defining DASH constants
private static final long serialVersionUID = -750240227063564211L;
public static final int DASH_INT = 60000;
public static final String DASH_STRING = "DASH";
private static LogManager logMgr = new
LogManager(ABCLevel.class.getName());
public static final Level DASH = new ABCLevel(DASH_INT, DASH_STRING, 0);
/**
* @param intValue - level
* @param levelName - level Name
* @param sysLogEquivalent - Equivalent sys log
*/
protected ABCLevel(final int intValue, final String levelName, final int
sysLogEquivalent) {
super(intValue, levelName, sysLogEquivalent);
}
/**
* @param val - integer value
* @return Level
*/
public static Level toLevel(final int val) {
logMgr.logMessage(ABCConstants.INFO,
"In ABCLevel,toLevel() begins val : " + val);
if (val == DASH_INT) {
return DASH;
}
logMgr.logMessage(ABCConstants.INFO,"In ABCLevel,toLevel(): ends");
return (Level) toLevel(val, Level.DEBUG);
}
}
The following is the MyEventEvaluator
public class MyEventEvaluatorimplements TriggeringEventEvaluator {
@Override
public boolean isTriggeringEvent(LoggingEvent event) {
if (event.getLevel() == ABCLevel.DASH)
return true;
else
return false;
}
}
The following is the Customized SMTP Appender
public class ABCSmtpAppender extends SMTPAppender {
@Override
public void setEvaluatorClass(String arg0) {
super.setEvaluatorClass(arg0);
}
@Override
public String getEvaluatorClass() {
return super.getEvaluatorClass();
}
}
--
View this message in context: http://old.nabble.com/ClassCirculatoryError-tp27336507p27336507.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org