diff --git a/pom.xml b/pom.xml
index 1230b5962..34edea710 100644
--- a/pom.xml
+++ b/pom.xml
@@ -174,6 +174,33 @@
+
+
+ org.slf4j
+ slf4j-api
+ 1.6.6
+ test
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ 1.6.6
+ test
+
+
+ org.slf4j
+ slf4j-log4j12
+ 1.6.6
+ test
+
+
+ log4j
+ log4j
+ 1.2.16
+ test
+
+
diff --git a/src/main/java/com/profiler/TomcatProfiler.java b/src/main/java/com/profiler/TomcatProfiler.java
index 7e2b6fdab..9fa8f6e71 100644
--- a/src/main/java/com/profiler/TomcatProfiler.java
+++ b/src/main/java/com/profiler/TomcatProfiler.java
@@ -29,6 +29,10 @@ public class TomcatProfiler implements ClassFileTransformer {
try {
ProfilerConfig profilerConfig = new ProfilerConfig();
profilerConfig.readConfigFile();
+ if (!profilerConfig.isProfileEnable()) {
+ logger.warning("Profiler Agent not started. PROFILE_ENABLE=" + profilerConfig.isProfileEnable());
+ return;
+ }
new TomcatProfiler(agentArgs, inst, profilerConfig);
} catch (Exception e) {
logger.log(Level.SEVERE, "Profiler Agent start fail. Cause:" + e.getMessage(), e);
diff --git a/src/main/java/com/profiler/config/ProfilerConfig.java b/src/main/java/com/profiler/config/ProfilerConfig.java
index 26b013d4d..36b4b0490 100644
--- a/src/main/java/com/profiler/config/ProfilerConfig.java
+++ b/src/main/java/com/profiler/config/ProfilerConfig.java
@@ -1,6 +1,7 @@
package com.profiler.config;
import com.profiler.common.util.PropertyUtils;
+import com.profiler.util.NumberUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -14,6 +15,7 @@ public class ProfilerConfig {
private static final Logger logger = Logger.getLogger(ProfilerConfig.class.getName());
+ private boolean profileEnable = true;
public static String SERVER_IP = "127.0.0.1";
public static int SERVER_UDP_PORT = 9995;
@@ -68,6 +70,10 @@ public class ProfilerConfig {
}
}
+ public boolean isProfileEnable() {
+ return profileEnable;
+ }
+
public boolean isJdbcProfile() {
return jdbcProfile;
}
@@ -91,6 +97,7 @@ public class ProfilerConfig {
private void readPropertyValues(Properties prop) {
// TODO : use Properties defaultvalue instead of using temp variable.
+ this.profileEnable = readBoolean(prop, "PROFILE_ENABLE", true);
this.SERVER_IP = readString(prop, "SERVER_IP", "127.0.0.1");
this.SERVER_UDP_PORT = readInt(prop, "SERVER_UDP_PORT", 9995);
@@ -148,12 +155,7 @@ public class ProfilerConfig {
private int readInt(Properties prop, String propertyName, int defaultValue) {
String value = prop.getProperty(propertyName);
- int result;
- try {
- result = Integer.parseInt(value);
- } catch (NumberFormatException e) {
- result = defaultValue;
- }
+ int result = NumberUtils.parseInteger(value, defaultValue);
if (logger.isLoggable(Level.INFO)) {
logger.info(propertyName + "=" + result);
}
diff --git a/src/test/java/com/profiler/dto/HeaderTest.java b/src/test/java/com/profiler/dto/HeaderTest.java
index b5780ecb4..f06bdbba4 100644
--- a/src/test/java/com/profiler/dto/HeaderTest.java
+++ b/src/test/java/com/profiler/dto/HeaderTest.java
@@ -1,20 +1,22 @@
package com.profiler.dto;
-import org.junit.Test;
-
import com.profiler.common.dto.Header;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import java.util.logging.Logger;
public class HeaderTest {
- private final Logger logger = Logger.getLogger(Header.class.getName());
+ private final Logger logger = LoggerFactory.getLogger(Header.class.getName());
@Test
public void testGetSignature() throws Exception {
Header header = new Header();
+
byte signature = header.getSignature();
+
System.out.println(signature);
short type = header.getType();
byte version = header.getVersion();
diff --git a/src/test/java/com/profiler/interceptor/InterceptorRegistryTest.java b/src/test/java/com/profiler/interceptor/InterceptorRegistryTest.java
index 836c3c162..8404c1cfb 100644
--- a/src/test/java/com/profiler/interceptor/InterceptorRegistryTest.java
+++ b/src/test/java/com/profiler/interceptor/InterceptorRegistryTest.java
@@ -1,24 +1,19 @@
package com.profiler.interceptor;
+import com.profiler.interceptor.bci.TestObject;
+import javassist.*;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Map;
-import java.util.logging.Logger;
-
-import com.profiler.interceptor.bci.TestObject;
-import javassist.CannotCompileException;
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.CtMethod;
-import javassist.NotFoundException;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
public class InterceptorRegistryTest {
- private final Logger logger = Logger.getLogger(InterceptorRegistryTest.class.getName());
+ private final Logger logger = LoggerFactory.getLogger(InterceptorRegistryTest.class.getName());
private InterceptorRegistry registry = new InterceptorRegistry();
diff --git a/src/test/java/com/profiler/interceptor/TestAfterInterceptor.java b/src/test/java/com/profiler/interceptor/TestAfterInterceptor.java
index b2f72b526..6d899cceb 100644
--- a/src/test/java/com/profiler/interceptor/TestAfterInterceptor.java
+++ b/src/test/java/com/profiler/interceptor/TestAfterInterceptor.java
@@ -1,10 +1,12 @@
package com.profiler.interceptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.Arrays;
-import java.util.logging.Logger;
public class TestAfterInterceptor implements StaticAfterInterceptor {
- private Logger logger = Logger.getLogger(this.getClass().getName());
+ private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
public int call = 0;
public Object target;
diff --git a/src/test/java/com/profiler/interceptor/TestBeforeInterceptor.java b/src/test/java/com/profiler/interceptor/TestBeforeInterceptor.java
index 599cc7f91..825315ae8 100644
--- a/src/test/java/com/profiler/interceptor/TestBeforeInterceptor.java
+++ b/src/test/java/com/profiler/interceptor/TestBeforeInterceptor.java
@@ -1,10 +1,12 @@
package com.profiler.interceptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.Arrays;
-import java.util.logging.Logger;
public class TestBeforeInterceptor implements StaticBeforeInterceptor {
- private Logger logger = Logger.getLogger(this.getClass().getName());
+ private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
public int call = 0;
public Object target;
diff --git a/src/test/java/com/profiler/interceptor/bci/JavaAssistClassTest.java b/src/test/java/com/profiler/interceptor/bci/JavaAssistClassTest.java
index f28adca9f..ffd1e4b74 100644
--- a/src/test/java/com/profiler/interceptor/bci/JavaAssistClassTest.java
+++ b/src/test/java/com/profiler/interceptor/bci/JavaAssistClassTest.java
@@ -1,20 +1,19 @@
package com.profiler.interceptor.bci;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.logging.Logger;
-
-import javassist.bytecode.Descriptor;
-
-import org.junit.Assert;
-import org.junit.Test;
-
import com.profiler.interceptor.TestAfterInterceptor;
import com.profiler.interceptor.TestBeforeInterceptor;
+import javassist.bytecode.Descriptor;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
public class JavaAssistClassTest {
- private Logger logger = Logger.getLogger(JavaAssistByteCodeInstrumentor.class.getName());
+ private Logger logger = LoggerFactory.getLogger(JavaAssistByteCodeInstrumentor.class.getName());
@Test
public void testBeforeAddInterceptor() throws Exception {
diff --git a/src/test/java/com/profiler/interceptor/bci/TestLog.java b/src/test/java/com/profiler/interceptor/bci/TestLog.java
index 29bf04738..286e06425 100644
--- a/src/test/java/com/profiler/interceptor/bci/TestLog.java
+++ b/src/test/java/com/profiler/interceptor/bci/TestLog.java
@@ -1,11 +1,13 @@
package com.profiler.interceptor.bci;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class TestLog {
- private final Logger logger = Logger.getLogger(TestLog.class.getName());
+ private final Logger logger = LoggerFactory.getLogger(TestLog.class.getName());
public String constructor;
diff --git a/src/test/java/com/profiler/interceptor/bci/TestObject.java b/src/test/java/com/profiler/interceptor/bci/TestObject.java
index ec8208acb..9f104a639 100644
--- a/src/test/java/com/profiler/interceptor/bci/TestObject.java
+++ b/src/test/java/com/profiler/interceptor/bci/TestObject.java
@@ -1,19 +1,20 @@
package com.profiler.interceptor.bci;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestObject {
- private Logger logger = Logger.getLogger(this.getClass().getName());
+ private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
private int callA;
- public int callA(){
+ public int callA() {
logger.info("callA");
int i = callA++;
return i;
}
- public String hello(String a) {
+ public String hello(String a) {
System.out.println("a:" + a);
System.out.println("test");
// throw new RuntimeException("test");
diff --git a/src/test/java/com/profiler/interceptor/bci/TestObject2.java b/src/test/java/com/profiler/interceptor/bci/TestObject2.java
index d04aca3e5..b7446babe 100644
--- a/src/test/java/com/profiler/interceptor/bci/TestObject2.java
+++ b/src/test/java/com/profiler/interceptor/bci/TestObject2.java
@@ -1,9 +1,10 @@
package com.profiler.interceptor.bci;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestObject2 {
- private Logger logger = Logger.getLogger(this.getClass().getName());
+ private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
public int callA;
public int callB;
diff --git a/src/test/java/com/profiler/modifier/db/mysql/MySQLConnectionImplModifierTest.java b/src/test/java/com/profiler/modifier/db/mysql/MySQLConnectionImplModifierTest.java
index eb2bd20ee..992214752 100644
--- a/src/test/java/com/profiler/modifier/db/mysql/MySQLConnectionImplModifierTest.java
+++ b/src/test/java/com/profiler/modifier/db/mysql/MySQLConnectionImplModifierTest.java
@@ -7,15 +7,15 @@ import com.profiler.util.TestClassLoader;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.Properties;
-import java.util.Set;
-import java.util.logging.Logger;
public class MySQLConnectionImplModifierTest {
- private final Logger logger = Logger.getLogger(MySQLConnectionImplModifierTest.class.getName());
+ private final Logger logger = LoggerFactory.getLogger(MySQLConnectionImplModifierTest.class.getName());
private TestClassLoader loader;
@Before
diff --git a/src/test/java/com/profiler/socket/UdpSocketTest.java b/src/test/java/com/profiler/socket/UdpSocketTest.java
index 8d097e62a..ba4542591 100644
--- a/src/test/java/com/profiler/socket/UdpSocketTest.java
+++ b/src/test/java/com/profiler/socket/UdpSocketTest.java
@@ -4,18 +4,18 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
import java.net.SocketException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class UdpSocketTest {
- private final Logger logger = Logger.getLogger(this.getClass().getName());
+ private final Logger logger = LoggerFactory.getLogger(this.getClass().getName());
private static int PORT = 9993;
// The correct maximum UDP message size is 65507, as determined by the following formula:
@@ -77,7 +77,7 @@ public class UdpSocketTest {
sender.send(packet1);
Assert.fail("실패해야 정상인데 성공.");
} catch (IOException e) {
- logger.log(Level.INFO, "메시지가 너무 크다. " + e.getMessage(), e);
+ logger.info("메시지가 너무 크다. " + e.getMessage(), e);
}
}
@@ -117,12 +117,12 @@ public class UdpSocketTest {
receiver.receive(datagramPacket);
logger.info("data size:" + datagramPacket.getLength());
} catch (IOException e) {
- logger.log(Level.WARNING, "receive error:" + e.getMessage(), e);
+ logger.warn("receive error:" + e.getMessage(), e);
}
}
}
-// @Test
+ // @Test
public void testRemoteSend() throws IOException, InterruptedException {
DatagramSocket send = new DatagramSocket();
send.connect(new InetSocketAddress("10.66.18.78", PORT));
@@ -141,7 +141,7 @@ public class UdpSocketTest {
send.send(newDatagramPacket(AcceptedSize));
try {
- send.send(newDatagramPacket(AcceptedSize+1));
+ send.send(newDatagramPacket(AcceptedSize + 1));
Assert.fail("실패");
} catch (IOException e) {
}
@@ -152,10 +152,10 @@ public class UdpSocketTest {
} catch (IOException e) {
}
- Thread.sleep(1000*3);
+ Thread.sleep(1000 * 3);
}
-// @Test
+ // @Test
public void createUdpSocket() throws IOException {
DatagramSocket so = new DatagramSocket();
// so.bind(new InetSocketAddress("localhost", 8081));
diff --git a/src/test/java/com/profiler/util/ArrayUtilsTest.java b/src/test/java/com/profiler/util/ArrayUtilsTest.java
index c58503999..22e1f423d 100644
--- a/src/test/java/com/profiler/util/ArrayUtilsTest.java
+++ b/src/test/java/com/profiler/util/ArrayUtilsTest.java
@@ -2,12 +2,11 @@ package com.profiler.util;
import org.junit.Assert;
import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ArrayUtilsTest {
- private final Logger logger = Logger.getLogger(ArrayUtilsTest.class.getName());
+ private final Logger logger = LoggerFactory.getLogger(ArrayUtilsTest.class.getName());
@Test
public void toStringTest() {
byte[] bytes = new byte[] {1, 2, 3, 4};
diff --git a/src/test/java/com/profiler/util/HeaderTBaseSerializerTest.java b/src/test/java/com/profiler/util/HeaderTBaseSerializerTest.java
index df89a01c0..d2cfd9241 100644
--- a/src/test/java/com/profiler/util/HeaderTBaseSerializerTest.java
+++ b/src/test/java/com/profiler/util/HeaderTBaseSerializerTest.java
@@ -1,20 +1,20 @@
package com.profiler.util;
-import java.util.Arrays;
-import java.util.logging.Logger;
-
-import org.junit.Assert;
-import org.junit.Test;
-
import com.profiler.common.dto.Header;
import com.profiler.common.dto.thrift.JVMInfoThriftDTO;
import com.profiler.common.util.DefaultTBaseLocator;
import com.profiler.common.util.HeaderTBaseDeserializer;
import com.profiler.common.util.HeaderTBaseSerializer;
import com.profiler.common.util.TBaseLocator;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
public class HeaderTBaseSerializerTest {
- private final Logger logger = Logger.getLogger(HeaderTBaseSerializerTest.class.getName());
+ private final Logger logger = LoggerFactory.getLogger(HeaderTBaseSerializerTest.class.getName());
@Test
diff --git a/src/test/java/com/profiler/util/HeaderUtilTest.java b/src/test/java/com/profiler/util/HeaderUtilTest.java
index 45f6ed839..798ccc0d3 100644
--- a/src/test/java/com/profiler/util/HeaderUtilTest.java
+++ b/src/test/java/com/profiler/util/HeaderUtilTest.java
@@ -2,17 +2,15 @@ package com.profiler.util;
import com.profiler.common.dto.Header;
import com.profiler.common.util.HeaderUtil;
-import com.profiler.dto.*;
import org.apache.thrift.TException;
import org.junit.Assert;
import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HeaderUtilTest {
- private final Logger logger = Logger.getLogger(this.getClass().getName());
+ private final Logger logger = LoggerFactory.getLogger(this.getClass().getName());
@Test
public void validateSignature() throws TException {
diff --git a/src/test/java/com/profiler/util/InstrumentTranslator.java b/src/test/java/com/profiler/util/InstrumentTranslator.java
index 1652c8a92..cdbacc942 100644
--- a/src/test/java/com/profiler/util/InstrumentTranslator.java
+++ b/src/test/java/com/profiler/util/InstrumentTranslator.java
@@ -1,15 +1,18 @@
package com.profiler.util;
import com.profiler.modifier.Modifier;
-import javassist.*;
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.NotFoundException;
+import javassist.Translator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class InstrumentTranslator implements Translator {
- private final Logger logger = Logger.getLogger(InstrumentTranslator.class.getName());
+ private final Logger logger = LoggerFactory.getLogger(InstrumentTranslator.class.getName());
private ConcurrentMap modifierMap = new ConcurrentHashMap();
@@ -30,9 +33,7 @@ public class InstrumentTranslator implements Translator {
@Override
public void onLoad(ClassPool pool, String classname) throws NotFoundException, CannotCompileException {
- if(logger.isLoggable(Level.FINE)) {
- logger.fine("loading className:" + classname);
- }
+ logger.debug("loading className:{}", classname);
Modifier modifier = modifierMap.get(classname);
if(modifier == null) {
diff --git a/src/test/java/com/profiler/util/JavaAssistUtilsTest.java b/src/test/java/com/profiler/util/JavaAssistUtilsTest.java
index a135ebee7..1912b213e 100644
--- a/src/test/java/com/profiler/util/JavaAssistUtilsTest.java
+++ b/src/test/java/com/profiler/util/JavaAssistUtilsTest.java
@@ -6,11 +6,11 @@ import javassist.CtMethod;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class JavaAssistUtilsTest {
- private final Logger logger = Logger.getLogger(JavaAssistUtilsTest.class.getName());
+ private final Logger logger = LoggerFactory.getLogger(JavaAssistUtilsTest.class.getName());
private ClassPool pool;
@Before
diff --git a/src/test/java/com/profiler/util/TestClassLoader.java b/src/test/java/com/profiler/util/TestClassLoader.java
index e389a7b0f..b60651536 100644
--- a/src/test/java/com/profiler/util/TestClassLoader.java
+++ b/src/test/java/com/profiler/util/TestClassLoader.java
@@ -1,28 +1,22 @@
package com.profiler.util;
-import java.util.logging.Logger;
-
-import com.profiler.util.bindvalue.BindValueConverter;
-import com.profiler.util.bindvalue.converter.Converter;
-import javassist.CannotCompileException;
-import javassist.Loader;
-import javassist.NotFoundException;
-
import com.profiler.StopWatch;
import com.profiler.context.Annotation;
import com.profiler.context.Trace;
-import com.profiler.interceptor.Interceptor;
-import com.profiler.interceptor.InterceptorRegistry;
-import com.profiler.interceptor.StaticAfterInterceptor;
-import com.profiler.interceptor.StaticAroundInterceptor;
-import com.profiler.interceptor.StaticBeforeInterceptor;
+import com.profiler.interceptor.*;
import com.profiler.interceptor.bci.ByteCodeInstrumentor;
import com.profiler.interceptor.bci.JavaAssistByteCodeInstrumentor;
import com.profiler.modifier.Modifier;
-import com.profiler.modifier.db.ConnectionTrace;
+import com.profiler.util.bindvalue.BindValueConverter;
+import javassist.CannotCompileException;
+import javassist.Loader;
+import javassist.NotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+//import java.util.logging.Logger;
public class TestClassLoader extends Loader {
- private final Logger logger = Logger.getLogger(TestClassLoader.class.getName());
+ private final Logger logger = LoggerFactory.getLogger(TestClassLoader.class.getName());
private ByteCodeInstrumentor instrumentor;
private InstrumentTranslator instrumentTranslator;