Moving to SLF4J
This commit is contained in:
parent
69dec45d88
commit
0345f21650
@ -139,6 +139,10 @@ subprojects {
|
||||
|
||||
dependencies {
|
||||
compile 'junit:junit:4.12'
|
||||
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
|
||||
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.+'
|
||||
// You can also use the JDK's built-in logging as the back end:
|
||||
// compile group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.7.5'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
@ -1,19 +0,0 @@
|
||||
// verifying/InfoLogging.java
|
||||
// (c)2016 MindView LLC: see Copyright.txt
|
||||
// We make no guarantees that this code is fit for any purpose.
|
||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||
// {ErrorOutputExpected}
|
||||
import org.apache.logging.log4j.*;
|
||||
|
||||
public class InfoLogging {
|
||||
private static final Logger logger =
|
||||
LogManager.getLogger(InfoLogging.class);
|
||||
public static void main(String[] args) {
|
||||
logger.info("Logging: INFO-level message");
|
||||
}
|
||||
}
|
||||
/* Output:
|
||||
___[ Error Output ]___
|
||||
Jul 27, 2016 10:50:39 AM InfoLogging main
|
||||
INFO: Logging: INFO-level message
|
||||
*/
|
16
verifying/SLF4JLogging.java
Normal file
16
verifying/SLF4JLogging.java
Normal file
@ -0,0 +1,16 @@
|
||||
// verifying/SLF4JLogging.java
|
||||
// (c)2016 MindView LLC: see Copyright.txt
|
||||
// We make no guarantees that this code is fit for any purpose.
|
||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||
import org.slf4j.*;
|
||||
|
||||
public class SLF4JLogging {
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(SLF4JLogging.class);
|
||||
public static void main(String[] args) {
|
||||
logger.info("hello logging");
|
||||
}
|
||||
}
|
||||
/* Output:
|
||||
17:58:42.798 [main] INFO SLF4JLogging - hello logging
|
||||
*/
|
@ -7,8 +7,8 @@ import java.util.*;
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
// So we can see the list objects being created,
|
||||
// and keep track of when they are cleaned up:
|
||||
// Keeps track of list objects as they are
|
||||
// created and cleaned up:
|
||||
class CountedList extends ArrayList<String> {
|
||||
private static int counter = 0;
|
||||
private int id = counter++;
|
||||
|
@ -1,14 +0,0 @@
|
||||
// verifying/log4j2.xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="Console" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
Loading…
x
Reference in New Issue
Block a user