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

log4j upgraded to log4j2

parent 552d40b5
package lcsb.mapviewer.cdplugin.copypaste; 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.PluginListOf;
import jp.sbi.celldesigner.plugin.PluginReaction; import jp.sbi.celldesigner.plugin.PluginReaction;
...@@ -21,7 +21,7 @@ public class CopyAction extends CopyPasteAbstractAction { ...@@ -21,7 +21,7 @@ public class CopyAction extends CopyPasteAbstractAction {
/** /**
* Default class logger. * 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 * Method that perform annotation of a CellDesigner species listed in
......
...@@ -3,7 +3,7 @@ package lcsb.mapviewer.cdplugin.copypaste; ...@@ -3,7 +3,7 @@ package lcsb.mapviewer.cdplugin.copypaste;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.Pair;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
...@@ -24,7 +24,7 @@ public class CopyPasteAbstractAction { ...@@ -24,7 +24,7 @@ public class CopyPasteAbstractAction {
* Default class logger. * Default class logger.
*/ */
@SuppressWarnings("unused") @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 * Prefix used for serialization/deserialization of {@link MiriamData} to string
......
...@@ -4,7 +4,7 @@ import java.awt.KeyEventDispatcher; ...@@ -4,7 +4,7 @@ import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager; import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.MainWindow; import jp.sbi.celldesigner.MainWindow;
import jp.sbi.celldesigner.plugin.CellDesignerPlugin; import jp.sbi.celldesigner.plugin.CellDesignerPlugin;
...@@ -32,7 +32,7 @@ public class CopyPastePlugin extends CellDesignerPlugin { ...@@ -32,7 +32,7 @@ public class CopyPastePlugin extends CellDesignerPlugin {
/** /**
* Default class logger. * Default class logger.
*/ */
private Logger logger = Logger.getLogger(CopyPastePlugin.class.getName()); private Logger logger = LogManager.getLogger(CopyPastePlugin.class.getName());
/** /**
* Main window of cell designer. * Main window of cell designer.
*/ */
......
...@@ -2,7 +2,7 @@ package lcsb.mapviewer.cdplugin.copypaste; ...@@ -2,7 +2,7 @@ package lcsb.mapviewer.cdplugin.copypaste;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.MainWindow; import jp.sbi.celldesigner.MainWindow;
import jp.sbi.celldesigner.plugin.PluginAction; import jp.sbi.celldesigner.plugin.PluginAction;
...@@ -20,7 +20,7 @@ public class CopyPluginAction extends PluginAction { ...@@ -20,7 +20,7 @@ public class CopyPluginAction extends PluginAction {
/** /**
* Default class logger. * 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; ...@@ -2,7 +2,7 @@ package lcsb.mapviewer.cdplugin.copypaste;
import java.util.Set; 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.PluginListOf;
import jp.sbi.celldesigner.plugin.PluginReaction; import jp.sbi.celldesigner.plugin.PluginReaction;
...@@ -25,7 +25,7 @@ public class PasteAction extends CopyPasteAbstractAction { ...@@ -25,7 +25,7 @@ public class PasteAction extends CopyPasteAbstractAction {
/** /**
* Default class logger. * 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 * Method that perform annotation of a CellDesigner species listed in
......
...@@ -2,7 +2,7 @@ package lcsb.mapviewer.cdplugin.copypaste; ...@@ -2,7 +2,7 @@ package lcsb.mapviewer.cdplugin.copypaste;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.MainWindow; import jp.sbi.celldesigner.MainWindow;
import jp.sbi.celldesigner.plugin.PluginAction; import jp.sbi.celldesigner.plugin.PluginAction;
...@@ -20,7 +20,7 @@ public class PastePluginAction extends PluginAction { ...@@ -20,7 +20,7 @@ public class PastePluginAction extends PluginAction {
/** /**
* Default class logger. * 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; ...@@ -18,7 +18,7 @@ import javax.swing.JScrollPane;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.JTextField; import javax.swing.JTextField;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias; import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
...@@ -66,7 +66,7 @@ public final class InfoFrame { ...@@ -66,7 +66,7 @@ public final class InfoFrame {
* Default class logger. * Default class logger.
*/ */
@SuppressWarnings("unused") @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. * Instance of the JFrame representation of windows.
......
...@@ -10,7 +10,7 @@ import java.util.List; ...@@ -10,7 +10,7 @@ import java.util.List;
import javax.swing.Timer; 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.CellDesignerPlugin;
import jp.sbi.celldesigner.plugin.PluginListOf; import jp.sbi.celldesigner.plugin.PluginListOf;
...@@ -43,7 +43,7 @@ public class InfoPlugin extends CellDesignerPlugin { ...@@ -43,7 +43,7 @@ public class InfoPlugin extends CellDesignerPlugin {
/** /**
* Default class logger. * 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. * Listener called when set of selected elements in cell designer changed.
......
...@@ -2,8 +2,9 @@ package lcsb.mapviewer.cdplugin; ...@@ -2,8 +2,9 @@ package lcsb.mapviewer.cdplugin;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import org.apache.log4j.spi.LoggingEvent; import org.apache.logging.log4j.core.LogEvent;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.mockito.Mockito; import org.mockito.Mockito;
...@@ -12,7 +13,8 @@ import jp.sbi.celldesigner.plugin.PluginListOf; ...@@ -12,7 +13,8 @@ import jp.sbi.celldesigner.plugin.PluginListOf;
import jp.sbi.celldesigner.plugin.PluginReaction; import jp.sbi.celldesigner.plugin.PluginReaction;
import jp.sbi.celldesigner.plugin.PluginSpecies; import jp.sbi.celldesigner.plugin.PluginSpecies;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias; import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
import lcsb.mapviewer.common.EventStorageLoggerAppender;
import lcsb.mapviewer.common.MinervaLoggerAppender;
public class CdPluginFunctions { public class CdPluginFunctions {
...@@ -27,29 +29,28 @@ public class CdPluginFunctions { ...@@ -27,29 +29,28 @@ public class CdPluginFunctions {
"</rdf:Description>\n" + "</rdf:Description>\n" +
"</rdf:RDF>\n"; "</rdf:RDF>\n";
private EventStorageLoggerAppender appender; private MinervaLoggerAppender appender;
@Before @Before
public final void _setUp() throws Exception { public final void _setUp() throws Exception {
Logger.getRootLogger().removeAppender(appender); MinervaLoggerAppender.unregisterLogEventStorage(appender);
appender = new EventStorageLoggerAppender(false); appender = MinervaLoggerAppender.createAppender(false);
Logger.getRootLogger().addAppender(appender);
} }
@After @After
public final void _tearDown() throws Exception { public final void _tearDown() throws Exception {
Logger.getRootLogger().removeAppender(appender); MinervaLoggerAppender.unregisterLogEventStorage(appender);
} }
protected List<LoggingEvent> getWarnings() { protected List<LogEvent> getWarnings() {
return appender.getWarnings(); return appender.getWarnings();
} }
protected List<LoggingEvent> getErrors() { protected List<LogEvent> getErrors() {
return appender.getErrors(); return appender.getErrors();
} }
protected List<LoggingEvent> getFatals() { protected List<LogEvent> getFatals() {
return appender.getFatals(); return appender.getFatals();
} }
......
...@@ -3,7 +3,7 @@ package lcsb.mapviewer.cdplugin.copypaste; ...@@ -3,7 +3,7 @@ package lcsb.mapviewer.cdplugin.copypaste;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
...@@ -12,7 +12,7 @@ import lcsb.mapviewer.cdplugin.CdPluginFunctions; ...@@ -12,7 +12,7 @@ import lcsb.mapviewer.cdplugin.CdPluginFunctions;
import lcsb.mapviewer.common.SystemClipboard; import lcsb.mapviewer.common.SystemClipboard;
public class CopyActionTest extends CdPluginFunctions { public class CopyActionTest extends CdPluginFunctions {
Logger logger = Logger.getLogger(CopyActionTest.class); Logger logger = LogManager.getLogger(CopyActionTest.class);
SystemClipboard cp = new SystemClipboard(); SystemClipboard cp = new SystemClipboard();
......
...@@ -6,7 +6,7 @@ import static org.junit.Assert.assertNull; ...@@ -6,7 +6,7 @@ import static org.junit.Assert.assertNull;
import java.util.Set; import java.util.Set;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
...@@ -17,7 +17,7 @@ import lcsb.mapviewer.model.map.MiriamRelationType; ...@@ -17,7 +17,7 @@ import lcsb.mapviewer.model.map.MiriamRelationType;
import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.MiriamType;
public class CopyPasteAbstractActionTest { public class CopyPasteAbstractActionTest {
Logger logger = Logger.getLogger(CopyPasteAbstractActionTest.class); Logger logger = LogManager.getLogger(CopyPasteAbstractActionTest.class);
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
......
...@@ -6,14 +6,14 @@ import java.util.ArrayList; ...@@ -6,14 +6,14 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import org.junit.Test; import org.junit.Test;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias; import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
import lcsb.mapviewer.cdplugin.CdPluginFunctions; import lcsb.mapviewer.cdplugin.CdPluginFunctions;
public class InfoFrameTest extends CdPluginFunctions { public class InfoFrameTest extends CdPluginFunctions {
Logger logger = Logger.getLogger(InfoFrameTest.class); Logger logger = LogManager.getLogger(InfoFrameTest.class);
@Test @Test
public void testSetEmptySpeciesList() { public void testSetEmptySpeciesList() {
......
...@@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals; ...@@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import org.junit.Test; import org.junit.Test;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias; import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
...@@ -13,7 +13,7 @@ import lcsb.mapviewer.cdplugin.CdPluginFunctions; ...@@ -13,7 +13,7 @@ import lcsb.mapviewer.cdplugin.CdPluginFunctions;
public class InfoPluginTest extends CdPluginFunctions { public class InfoPluginTest extends CdPluginFunctions {
Logger logger = Logger.getLogger(InfoPluginTest.class); Logger logger = LogManager.getLogger(InfoPluginTest.class);
@Test @Test
public void testConstructor() { 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 @@ ...@@ -65,11 +65,34 @@
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<!-- Log4J --> <!-- Log4J2 -->
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-api</artifactId>
<version>${log4j.version}</version> <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> </dependency>
<!-- XML parser --> <!-- XML parser -->
...@@ -154,23 +177,6 @@ ...@@ -154,23 +177,6 @@
<version>${springframework.version}</version> <version>${springframework.version}</version>
</dependency> </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 --> <!-- Utils used for connection via http -->
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
......
...@@ -3,7 +3,7 @@ package lcsb.mapviewer.annotation.cache; ...@@ -3,7 +3,7 @@ package lcsb.mapviewer.annotation.cache;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger; import org.apache.logging.log4j.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.w3c.dom.Node; import org.w3c.dom.Node;
...@@ -31,7 +31,7 @@ public final class ApplicationLevelCache implements QueryCacheInterface { ...@@ -31,7 +31,7 @@ public final class ApplicationLevelCache implements QueryCacheInterface {
/** /**
* Default class logger. * Default class logger.
*/ */
private static Logger logger = Logger.getLogger(ApplicationLevelCache.class); private static Logger logger = LogManager.getLogger(ApplicationLevelCache.class);
/** /**