Better fix for last commit

This commit is contained in:
snowleo 2012-11-19 22:03:25 +01:00
parent 1363406b84
commit 0b1625f4c1
2 changed files with 15 additions and 13 deletions

View file

@ -1,9 +1,11 @@
package com.earth2me.essentials.protect; package com.earth2me.essentials.protect;
import com.earth2me.essentials.protect.data.IProtectedBlock; import com.earth2me.essentials.protect.data.IProtectedBlock;
import com.mchange.v2.log.MLevel;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.logging.Filter; import java.util.logging.Filter;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
@ -27,24 +29,20 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
@Override @Override
public void onLoad() public void onLoad()
{ {
try { try
{
// Simple fix for the case that log4j is on the class path by another plugin // Simple fix for the case that log4j is on the class path by another plugin
Class basicConfiguratorClass = Class.forName("org.apache.log4j.BasicConfigurator"); Class propertyConfiguratorClass = Class.forName("org.apache.log4j.PropertyConfigurator");
basicConfiguratorClass.getMethod("configure").invoke(null); Properties properties = new Properties();
properties.load(this.getClass().getResourceAsStream("log4j.properties"));
propertyConfiguratorClass.getMethod("configure", Properties.class).invoke(null, properties);
} }
catch (Exception ex) catch (Exception ex)
{ {
//Ignore me, log4j not found on classloader. //Ignore me, log4j not found on classloader.
} }
C3P0logger = com.mchange.v2.log.MLog.getLogger(com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.class); C3P0logger = com.mchange.v2.log.MLog.getLogger(com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.class);
C3P0logger.setFilter(new Filter() C3P0logger.setLevel(MLevel.WARNING);
{
public boolean isLoggable(LogRecord lr)
{
return lr.getLevel() != Level.INFO;
}
});
} }
public void onEnable() public void onEnable()

View file

@ -0,0 +1,4 @@
log4j.rootLogger=INFO, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n