aboutsummaryrefslogtreecommitdiff
path: root/juick-core
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-10 04:50:07 +0700
committerGravatar Vitaly Takmazov2016-11-10 21:41:14 +0300
commit09221ab5695e99b2df1130ea923c39625ec85429 (patch)
tree58c775188d25239a1e32a83f8007e5f1679d49ee /juick-core
parent705d4f87c97dfa20eb6daa88b93ff124fa401b92 (diff)
using slf4j + logback for logging
Diffstat (limited to 'juick-core')
-rw-r--r--juick-core/build.gradle13
-rw-r--r--juick-core/src/main/java/com/juick/json/MessageSerializer.java8
-rw-r--r--juick-core/src/main/resources/logback.xml13
3 files changed, 29 insertions, 5 deletions
diff --git a/juick-core/build.gradle b/juick-core/build.gradle
index 0008642e..30802dad 100644
--- a/juick-core/build.gradle
+++ b/juick-core/build.gradle
@@ -5,13 +5,24 @@ repositories {
mavenCentral()
}
+def jacksonVersion = '2.8.4'
+def logbackVersion = '1.1.7'
+def slf4jVersion = '1.7.21'
+
dependencies {
compile project(':deps:com.juick.xmpp')
- def jacksonVersion = '2.8.4'
+
compile "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
compile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
compile "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${jacksonVersion}"
+ compile "ch.qos.logback:logback-classic:${logbackVersion}"
+ compile "ch.qos.logback:logback-core:${logbackVersion}"
+ compile "ch.qos.logback:logback-access:${logbackVersion}"
+ compile "org.slf4j:slf4j-api:${slf4jVersion}"
+ compile "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
+ compile "org.slf4j:log4j-over-slf4j:${slf4jVersion}"
+ compile "org.slf4j:jul-to-slf4j:${slf4jVersion}"
compile 'org.apache.httpcomponents:httpclient:4.5.2'
compile 'org.apache.commons:commons-lang3:3.5'
compile "org.springframework:spring-jdbc:4.3.4.RELEASE"
diff --git a/juick-core/src/main/java/com/juick/json/MessageSerializer.java b/juick-core/src/main/java/com/juick/json/MessageSerializer.java
index 9da828c9..3ef903f0 100644
--- a/juick-core/src/main/java/com/juick/json/MessageSerializer.java
+++ b/juick-core/src/main/java/com/juick/json/MessageSerializer.java
@@ -22,12 +22,12 @@ import com.juick.Tag;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.stream.Collectors;
/**
@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
*/
public class MessageSerializer extends JSONSerializer<Message> {
- private final static Logger LOGGER = Logger.getLogger(MessageSerializer.class.getName());
+ private final static Logger LOGGER = LoggerFactory.getLogger(MessageSerializer.class);
UserSerializer userSerializer = new UserSerializer();
PlaceSerializer placeSerializer = new PlaceSerializer();
@@ -133,7 +133,7 @@ public class MessageSerializer extends JSONSerializer<Message> {
json.put("photo", photo);
}
} catch (JSONException e) {
- LOGGER.log(Level.SEVERE, "JSON Exception", e);
+ LOGGER.error("JSON Exception", e);
}
return json;
diff --git a/juick-core/src/main/resources/logback.xml b/juick-core/src/main/resources/logback.xml
new file mode 100644
index 00000000..9e3bf16c
--- /dev/null
+++ b/juick-core/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration> \ No newline at end of file