log4j support introduced

This commit is contained in:
romanman 2014-05-22 20:26:01 +03:00
parent 537f614442
commit 567e2e4f8a
5 changed files with 77 additions and 16 deletions

View File

@ -87,21 +87,48 @@ mvn clean package -Dmaven.test.skip=true
</dependency>
<!-- Consumers are expected to provide their own SLF4J adapters such as
logback, slf4j-log4j12, slf4j-jcl and so on see http://www.slf4j.org/faq.html -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- remove the real commons-logging from classpath -->
<!-- declare as provided or exclude from spring jars -->
<dependency>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<!-- add slf4j interfaces to classpath -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
<scope>compile</scope>
</dependency>
<!-- add commons logging to slf4j bridge to classpath -->
<!-- acts as jcl but routes commons-logging calls to slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.5.6</version>
<scope>runtime</scope>
</dependency>
<!-- add log4j binding to classpath -->
<!-- routes slf4j calls to log4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
<scope>runtime</scope>
</dependency>
<!-- add log4j to classpath -->
<!-- does the logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.yuvalshavit</groupId>
<artifactId>antlr-denter</artifactId>

View File

@ -1,6 +1,9 @@
package org.ethereum.gui;
import org.ethereum.manager.MainData;
import org.ethereum.util.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
@ -17,6 +20,8 @@ import java.awt.event.ItemListener;
*/
public class ToolBar extends JFrame {
Logger logger = LoggerFactory.getLogger(getClass());
ConnectionConsoleWindow connectionConsoleWindow = null;
PeersTableWindow mainFrame = null;
BlockChainTable blockChainWindow = null;
@ -25,6 +30,19 @@ public class ToolBar extends JFrame {
public ToolBar() throws HeadlessException {
logger.info("EthereumJ [v0.5.1] by Roman Mandeleil");
logger.info(" design by Vitaly Buterin");
logger.info("");
logger.info("java.version: " + System.getProperty("java.version"));
logger.info("java.home: " + System.getProperty("java.home"));
if (Utils.JAVA_VERSION < 1.7) {
logger.info("EthereumJ support version 1.7 and higher of Java Runtime please update");
System.exit(0);
}
final JPanel cp = new JPanel(new FlowLayout());
cp.setBackground(Color.WHITE);

View File

@ -72,8 +72,6 @@ public class PeerTaster {
e.printStackTrace();
}
}
System.out.println("I am dead");
}

View File

@ -47,4 +47,14 @@ public class Utils {
public static SecureRandom getRandom(){
return random;
}
public static double JAVA_VERSION = getJavaVersion();
static double getJavaVersion() {
String version = System.getProperty("java.version");
int pos = 0, count = 0;
for ( ; pos<version.length() && count < 2; pos ++) {
if (version.charAt(pos) == '.') count ++;
}
return Double.parseDouble (version.substring (0, pos - 1));
}
}

View File

@ -0,0 +1,8 @@
# Root logger option
log4j.rootLogger=INFO, stdout
# Direct log messages to stdout
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{HH:mm:ss} %c{1}: %m%n