Gitlab is now using https://gitlab.lcsb.uni.lu as it's primary address. Please update your bookmarks. FAQ.

Commit a21d5d1d authored by Piotr Gawron's avatar Piotr Gawron
Browse files

log4j upgraded to log4j2

parent 552d40b5
package lcsb.mapviewer.cdplugin.copypaste;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.plugin.PluginListOf;
import jp.sbi.celldesigner.plugin.PluginReaction;
......@@ -21,7 +21,7 @@ public class CopyAction extends CopyPasteAbstractAction {
/**
* Default class logger.
*/
private final Logger logger = Logger.getLogger(CopyAction.class.getName());
private final Logger logger = LogManager.getLogger(CopyAction.class.getName());
/**
* Method that perform annotation of a CellDesigner species listed in
......
......@@ -3,7 +3,7 @@ package lcsb.mapviewer.cdplugin.copypaste;
import java.util.HashSet;
import java.util.Set;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import lcsb.mapviewer.common.Pair;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
......@@ -24,7 +24,7 @@ public class CopyPasteAbstractAction {
* Default class logger.
*/
@SuppressWarnings("unused")
private final Logger logger = Logger.getLogger(CopyPasteAbstractAction.class);
private final Logger logger = LogManager.getLogger(CopyPasteAbstractAction.class);
/**
* Prefix used for serialization/deserialization of {@link MiriamData} to string
......
......@@ -4,7 +4,7 @@ import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.MainWindow;
import jp.sbi.celldesigner.plugin.CellDesignerPlugin;
......@@ -32,7 +32,7 @@ public class CopyPastePlugin extends CellDesignerPlugin {
/**
* Default class logger.
*/
private Logger logger = Logger.getLogger(CopyPastePlugin.class.getName());
private Logger logger = LogManager.getLogger(CopyPastePlugin.class.getName());
/**
* Main window of cell designer.
*/
......
......@@ -2,7 +2,7 @@ package lcsb.mapviewer.cdplugin.copypaste;
import java.awt.event.ActionEvent;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.MainWindow;
import jp.sbi.celldesigner.plugin.PluginAction;
......@@ -20,7 +20,7 @@ public class CopyPluginAction extends PluginAction {
/**
* Default class logger.
*/
private Logger logger = Logger.getLogger(PasteAction.class.getName());
private Logger logger = LogManager.getLogger(PasteAction.class.getName());
/**
*
......
......@@ -2,7 +2,7 @@ package lcsb.mapviewer.cdplugin.copypaste;
import java.util.Set;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.plugin.PluginListOf;
import jp.sbi.celldesigner.plugin.PluginReaction;
......@@ -25,7 +25,7 @@ public class PasteAction extends CopyPasteAbstractAction {
/**
* Default class logger.
*/
private final Logger logger = Logger.getLogger(PasteAction.class.getName());
private final Logger logger = LogManager.getLogger(PasteAction.class.getName());
/**
* Method that perform annotation of a CellDesigner species listed in
......
......@@ -2,7 +2,7 @@ package lcsb.mapviewer.cdplugin.copypaste;
import java.awt.event.ActionEvent;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.MainWindow;
import jp.sbi.celldesigner.plugin.PluginAction;
......@@ -20,7 +20,7 @@ public class PastePluginAction extends PluginAction {
/**
* Default class logger.
*/
private Logger logger = Logger.getLogger(PasteAction.class.getName());
private Logger logger = LogManager.getLogger(PasteAction.class.getName());
/**
*
*/
......
......@@ -18,7 +18,7 @@ import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
......@@ -66,7 +66,7 @@ public final class InfoFrame {
* Default class logger.
*/
@SuppressWarnings("unused")
private final Logger logger = Logger.getLogger(InfoFrame.class);
private final Logger logger = LogManager.getLogger(InfoFrame.class);
/**
* Instance of the JFrame representation of windows.
......
......@@ -10,7 +10,7 @@ import java.util.List;
import javax.swing.Timer;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.plugin.CellDesignerPlugin;
import jp.sbi.celldesigner.plugin.PluginListOf;
......@@ -43,7 +43,7 @@ public class InfoPlugin extends CellDesignerPlugin {
/**
* Default class logger.
*/
private Logger logger = Logger.getLogger(InfoPlugin.class.getName());
private Logger logger = LogManager.getLogger(InfoPlugin.class.getName());
/**
* Listener called when set of selected elements in cell designer changed.
......
......@@ -2,8 +2,9 @@ package lcsb.mapviewer.cdplugin;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.logging.log4j.*;
import org.apache.logging.log4j.core.LogEvent;
import org.junit.After;
import org.junit.Before;
import org.mockito.Mockito;
......@@ -12,7 +13,8 @@ import jp.sbi.celldesigner.plugin.PluginListOf;
import jp.sbi.celldesigner.plugin.PluginReaction;
import jp.sbi.celldesigner.plugin.PluginSpecies;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
import lcsb.mapviewer.common.EventStorageLoggerAppender;
import lcsb.mapviewer.common.MinervaLoggerAppender;
public class CdPluginFunctions {
......@@ -27,29 +29,28 @@ public class CdPluginFunctions {
"</rdf:Description>\n" +
"</rdf:RDF>\n";
private EventStorageLoggerAppender appender;
private MinervaLoggerAppender appender;
@Before
public final void _setUp() throws Exception {
Logger.getRootLogger().removeAppender(appender);
appender = new EventStorageLoggerAppender(false);
Logger.getRootLogger().addAppender(appender);
MinervaLoggerAppender.unregisterLogEventStorage(appender);
appender = MinervaLoggerAppender.createAppender(false);
}
@After
public final void _tearDown() throws Exception {
Logger.getRootLogger().removeAppender(appender);
MinervaLoggerAppender.unregisterLogEventStorage(appender);
}
protected List<LoggingEvent> getWarnings() {
protected List<LogEvent> getWarnings() {
return appender.getWarnings();
}
protected List<LoggingEvent> getErrors() {
protected List<LogEvent> getErrors() {
return appender.getErrors();
}
protected List<LoggingEvent> getFatals() {
protected List<LogEvent> getFatals() {
return appender.getFatals();
}
......
......@@ -3,7 +3,7 @@ package lcsb.mapviewer.cdplugin.copypaste;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.junit.Test;
import org.mockito.Mockito;
......@@ -12,7 +12,7 @@ import lcsb.mapviewer.cdplugin.CdPluginFunctions;
import lcsb.mapviewer.common.SystemClipboard;
public class CopyActionTest extends CdPluginFunctions {
Logger logger = Logger.getLogger(CopyActionTest.class);
Logger logger = LogManager.getLogger(CopyActionTest.class);
SystemClipboard cp = new SystemClipboard();
......
......@@ -6,7 +6,7 @@ import static org.junit.Assert.assertNull;
import java.util.Set;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
......@@ -17,7 +17,7 @@ import lcsb.mapviewer.model.map.MiriamRelationType;
import lcsb.mapviewer.model.map.MiriamType;
public class CopyPasteAbstractActionTest {
Logger logger = Logger.getLogger(CopyPasteAbstractActionTest.class);
Logger logger = LogManager.getLogger(CopyPasteAbstractActionTest.class);
@Before
public void setUp() throws Exception {
......
......@@ -6,14 +6,14 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.junit.Test;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
import lcsb.mapviewer.cdplugin.CdPluginFunctions;
public class InfoFrameTest extends CdPluginFunctions {
Logger logger = Logger.getLogger(InfoFrameTest.class);
Logger logger = LogManager.getLogger(InfoFrameTest.class);
@Test
public void testSetEmptySpeciesList() {
......
......@@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.junit.Test;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
......@@ -13,7 +13,7 @@ import lcsb.mapviewer.cdplugin.CdPluginFunctions;
public class InfoPluginTest extends CdPluginFunctions {
Logger logger = Logger.getLogger(InfoPluginTest.class);
Logger logger = LogManager.getLogger(InfoPluginTest.class);
@Test
public void testConstructor() {
......
#Set root logger 's level and its appender to an appender called CONSOLE which is defined below.
log4j.rootLogger=info, CONSOLE
#Set the behavior of the CONSOLE appender
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n
#log4j.appender.CONSOLE.layout.ConversionPattern=%m%n
#Set the behavior of the FILE appender
log4j.appender.R=org.apache.log4j.FileAppender
log4j.appender.R.File=${catalina.home}/logs/MapViewer.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n
log4j.logger.org.springframework=warn
log4j.logger.org.hibernate=warn
log4j.logger.lcsb=debug
rootLogger.level = INFO
appenders = console
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d %5p [%t] (%F:%L) - %m%n
rootLogger.appenderRefs = console
rootLogger.appenderRef.console.ref = STDOUT
logger.minerva.name = lcsb
logger.minerva.level = debug
logger.minerva-persist.name = lcsb.mapviewer.persist.DbUtils
logger.minerva-persist.level = info
logger.minerva-cache.name = lcsb.mapviewer.annotation.cache
logger.minerva-cache.level = info
logger.springframework.name = org.springframework
logger.springframework.level = warn
logger.hibernate.name = org.hibernate
logger.hibernate.level = warn
......@@ -65,11 +65,34 @@
<version>1.0</version>
</dependency>
<!-- Log4J -->
<!-- Log4J2 -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<!-- Spring uses commons-logging, so: https://stackoverflow.com/a/41475146/1127920 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<!-- XML parser -->
......@@ -154,23 +177,6 @@
<version>${springframework.version}</version>
</dependency>
<!-- Miriam registry API -->
<dependency>
<groupId>uk.ac.ebi.miriam</groupId>
<artifactId>miriam-lib</artifactId>
<version>${miriam-lib.version}</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Utils used for connection via http -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
......
......@@ -3,7 +3,7 @@ package lcsb.mapviewer.annotation.cache;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.springframework.stereotype.Service;
import org.w3c.dom.Node;
......@@ -31,7 +31,7 @@ public final class ApplicationLevelCache implements QueryCacheInterface {
/**
* Default class logger.
*/
private static Logger logger = Logger.getLogger(ApplicationLevelCache.class);
private static Logger logger = LogManager.getLogger(ApplicationLevelCache.class);
/**
* Cached nodes stored locally and identified by string.
......
......@@ -27,7 +27,7 @@ import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.common.Configuration;
......@@ -58,7 +58,7 @@ public class BigFileCache {
/**
* Default class logger.
*/
private Logger logger = Logger.getLogger(BigFileCache.class);
private Logger logger = LogManager.getLogger(BigFileCache.class);
/**
* Access class for database objects storing statuses of the files.
......
......@@ -3,7 +3,7 @@ package lcsb.mapviewer.annotation.cache;
import java.io.IOException;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.w3c.dom.Node;
......@@ -23,7 +23,7 @@ public abstract class CachableInterface {
/**
* Default class logger.
*/
private static Logger logger = Logger.getLogger(CachableInterface.class);
private static Logger logger = LogManager.getLogger(CachableInterface.class);
/**
* Refresh cache data from original source.
......
package lcsb.mapviewer.annotation.cache;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
......@@ -26,7 +26,7 @@ public class GeneralCache implements GeneralCacheInterface {
* Default class logger.
*/
@SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(GeneralCache.class);
private static Logger logger = LogManager.getLogger(GeneralCache.class);
/**
* Application level cache. More information can be found
......
package lcsb.mapviewer.annotation.cache;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.w3c.dom.Node;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
......@@ -22,7 +22,7 @@ public class GeneralCacheWithExclusion implements GeneralCacheInterface {
/**
* Default class logger.
*/
private Logger logger = Logger.getLogger(GeneralCacheWithExclusion.class);
private Logger logger = LogManager.getLogger(GeneralCacheWithExclusion.class);
/**
* How many queries should be ignored.
......
......@@ -13,7 +13,7 @@ import java.util.concurrent.ThreadFactory;
import javax.annotation.PostConstruct;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -406,7 +406,7 @@ public class PermanentDatabaseLevelCache implements PermanentDatabaseLevelCacheI
/**
* Default class logger.
*/
private static Logger logger = Logger.getLogger(PermanentDatabaseLevelCache.class);
private static Logger logger = LogManager.getLogger(PermanentDatabaseLevelCache.class);
/**
* Data access object for query entries accessed by string key.
......
......@@ -15,7 +15,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import lcsb.mapviewer.annotation.services.WrongResponseCodeIOException;
......@@ -36,7 +36,7 @@ public class WebPageDownloader {
/**
* Default class logger.
*/
private final Logger logger = Logger.getLogger(WebPageDownloader.class);
private final Logger logger = LogManager.getLogger(WebPageDownloader.class);
/**
* Hard timeout (threads are terminated) of http connection that access data
......
......@@ -8,7 +8,7 @@ import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import org.apache.commons.lang3.SerializationException;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import org.w3c.dom.Node;
/**
......@@ -25,7 +25,7 @@ public class XmlSerializer<T> {
/**
* Default class logger.
*/
private final Logger logger = Logger.getLogger(XmlSerializer.class);
private final Logger logger = LogManager.getLogger(XmlSerializer.class);
/**
* Class of the object that DAO works on.
......
......@@ -6,7 +6,7 @@ import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import uk.ac.ebi.chebi.webapps.chebiWS.model.DataItem;
import uk.ac.ebi.chebi.webapps.chebiWS.model.Entity;
......@@ -30,7 +30,7 @@ public class Chebi implements Serializable {
* Default class logger.
*/
@SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(Chebi.class);
private static Logger logger = LogManager.getLogger(Chebi.class);
/**
* Name of the object.
......
......@@ -8,7 +8,7 @@ import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.*;
import lcsb.mapviewer.common.comparator.StringComparator;
import lcsb.mapviewer.model.map.MiriamData;
......@@ -30,7 +30,7 @@ public class Drug implements Serializable, TargettingStructure {
/**
* Default class logger.
*/