Merge branch 'master' of https://github.com/eugenp/tutorials into gcasanova-master

This commit is contained in:
Zeger Hendrikse 2016-07-08 13:34:47 +02:00
commit bb7b2f2297
9 changed files with 204 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.Range;
import com.google.common.collect.Sets;
import com.google.common.collect.Table;
import com.google.common.collect.TreeRangeMap;
import com.google.common.io.Files;
import org.assertj.guava.data.MapEntry;
@ -78,7 +79,7 @@ public class AssertJGuavaTest {
@Test
public void givenTable_whenVerifying_thenShouldBeCorrect() throws Exception {
final HashBasedTable<Integer, String, String> table = HashBasedTable.create(2, 2);
final Table<Integer, String, String> table = HashBasedTable.create(2, 2);
table.put(1, "A", "PRESENT");
table.put(1, "B", "ABSENT");

66
log4j/pom.xml Normal file
View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>log4j</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!--log4j dependencies-->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!--log4j2 dependencies-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6</version>
</dependency>
<!--disruptor for log4j2 async logging-->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.3.4</version>
</dependency>
<!--logback dependencies-->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<debug>true</debug>
<optimize>true</optimize>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,17 @@
package com.baeldung.log4j;
import org.apache.log4j.Logger;
public class Log4jExample {
private final static Logger logger = Logger.getLogger(Log4jExample.class);
public static void main(String[] args) {
logger.trace("Trace log message");
logger.debug("Debug log message");
logger.info("Info log message");
logger.error("Error log message");
}
}

View File

@ -0,0 +1,16 @@
package com.baeldung.log4j2;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
public class Log4j2Example {
private static final Logger logger = LogManager.getLogger(Log4j2Example.class);
public static void main(String[] args) {
logger.debug("Debug log message");
logger.info("Info log message");
logger.error("Error log message");
}
}

View File

@ -0,0 +1,16 @@
package com.baeldung.logback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LogbackExample {
private static final Logger logger = LoggerFactory.getLogger(LogbackExample.class);
public static void main(String[] args) {
logger.debug("Debug log message");
logger.info("Info log message");
logger.error("Error log message");
}
}

View File

@ -0,0 +1,32 @@
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
<log4j:configuration debug="false">
<!--Console appender-->
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %p %m%n"/>
</layout>
</appender>
<!-- File appender-->
<appender name="fout" class="org.apache.log4j.FileAppender">
<param name="file" value="log4j/target/baeldung-log4j.log"/>
<param name="append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n"/>
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %p %m%n"/>
</layout>
</appender>
<!--Override log level for specified package-->
<category name="com.baeldung.log4j">
<priority value="TRACE"/>
</category>
<root>
<level value="DEBUG"/>
<appender-ref ref="stdout"/>
<appender-ref ref="fout"/>
</root>
</log4j:configuration>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
# Console appender
<Console name="stdout" target="SYSTEM_OUT">
# Pattern of log message for console appender
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %p %m%n"/>
</Console>
# File appender
<File name="fout" fileName="log4j/target/baeldung-log4j2.log" immediateFlush="false" append="false">
# Pattern of log message for file appender
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %p %m%n"/>
</File>
</Appenders>
<Loggers>
# Override log level for specified package
<Logger name="com.baeldung.log4j2" level="TRACE"/>
<AsyncRoot level="DEBUG">
<AppenderRef ref="stdout"/>
<AppenderRef ref="fout"/>
</AsyncRoot>
</Loggers>
</Configuration>

View File

@ -0,0 +1,28 @@
<configuration>
# Console appender
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
# Pattern of log message for console appender
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %p %m%n</Pattern>
</layout>
</appender>
# File appender
<appender name="fout" class="ch.qos.logback.core.FileAppender">
# Name of a log file
<file>log4j/target/baeldung-logback.log</file>
<append>false</append>
<encoder>
# Pattern of log message for file appender
<pattern>%d{yyyy-MM-dd HH:mm:ss} %p %m%n</pattern>
</encoder>
</appender>
# Override log level for specified package
<logger name="com.baeldung.logback" level="TRACE"/>
<root level="DEBUG">
<appender-ref ref="stdout"/>
<appender-ref ref="fout"/>
</root>
</configuration>

View File

@ -36,6 +36,7 @@
<!-- <module>raml</module> -->
<module>rest-testing</module>
<module>resteasy</module>
<module>log4j</module>
<module>spring-all</module>
<module>spring-apache-camel</module>