File tree 10 files changed +106
-46
lines changed
console-captor-with-log4j-slf4j18
main/java/nl/altindag/console/log4j
java/nl/altindag/console/log4j
log-captor-with-log4j-slf4j18/src
main/java/nl/altindag/log4j
test/java/nl/altindag/log4j
10 files changed +106
-46
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,10 @@ A repository containing different java tutorials
13
13
- [ Unit Testing Static Methods with Mockito] ( mock-statics-with-mockito )
14
14
- [ Unit Testing Java Util Logging logs with LogCaptor] ( log-captor-examples/log-captor-with-java-util-logging )
15
15
- [ Unit Testing Log4J logs with LogCaptor] ( log-captor-examples/log-captor-with-log4j-core )
16
- - [ Unit testing Log4J logs with LogCaptor while using log4j-slf4j18-impl] ( log-captor-examples/log-captor-with-log4j-slf4j18 )
17
16
- [ Unit Testing SLF4J Logback logs with LogCaptor] ( log-captor-examples/log-captor-with-slf4j-logback-classic )
18
17
- [ Unit Testing SLF4J Log4j logs with LogCaptor] ( log-captor-examples/log-captor-with-slf4j-log4j )
19
18
- [ Unit Testing Spring Boot Log4j2 logs with LogCaptor] ( log-captor-examples/log-captor-with-spring-boot-starter-log4j2 )
19
+ - [ Unit testing logs with ConsoleCaptor while using log4j-slf4j18-impl] ( console-captor-examples/console-captor-with-log4j-slf4j18 )
20
20
21
21
## Security 🔐
22
22
- [ Instant Server SSL Reloading with Spring Boot and Jetty] ( instant-server-ssl-reloading )
Original file line number Diff line number Diff line change 5
5
<modelVersion >4.0.0</modelVersion >
6
6
7
7
<parent >
8
- <artifactId >log -captor-examples-parent</artifactId >
8
+ <artifactId >console -captor-examples-parent</artifactId >
9
9
<groupId >io.github.hakky54</groupId >
10
10
<version >1.0.0-SNAPSHOT</version >
11
11
</parent >
12
12
13
- <artifactId >log -captor-with-log4j-slf4j18</artifactId >
13
+ <artifactId >console -captor-with-log4j-slf4j18</artifactId >
14
14
<version >1.0.0-SNAPSHOT</version >
15
15
<packaging >jar</packaging >
16
16
19
19
<groupId >org.apache.logging.log4j</groupId >
20
20
<artifactId >log4j-slf4j18-impl</artifactId >
21
21
<version >${version.log4j-log4j-slf4j18} </version >
22
- <exclusions >
23
- <exclusion >
24
- <groupId >org.slf4j</groupId >
25
- <artifactId >slf4j-api</artifactId >
26
- </exclusion >
27
- </exclusions >
28
22
</dependency >
29
23
</dependencies >
30
24
25
+
31
26
</project >
Original file line number Diff line number Diff line change
1
+ package nl .altindag .console .log4j ;
2
+
3
+ import org .slf4j .Logger ;
4
+ import org .slf4j .LoggerFactory ;
5
+
6
+ public class FooService {
7
+
8
+ private static final Logger LOGGER = LoggerFactory .getLogger (FooService .class );
9
+
10
+ public void hello () {
11
+ LOGGER .info ("Hello there friend!" );
12
+ }
13
+
14
+ public static void main (String [] args ) {
15
+ new FooService ().hello ();
16
+ }
17
+
18
+ }
Original file line number Diff line number Diff line change
1
+ package nl .altindag .console .log4j ;
2
+
3
+ import nl .altindag .console .ConsoleCaptor ;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ import static org .assertj .core .api .Assertions .assertThat ;
7
+
8
+ class FooServiceShould {
9
+
10
+ @ Test
11
+ void sayHello () {
12
+ ConsoleCaptor consoleCaptor = new ConsoleCaptor ();
13
+
14
+ FooService fooService = new FooService ();
15
+ fooService .hello ();
16
+
17
+ assertThat (consoleCaptor .getStandardOutput ()).hasSize (1 );
18
+ assertThat (consoleCaptor .getStandardOutput ().get (0 )).contains ("Hello there friend!" );
19
+ }
20
+
21
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <Configuration status =" INFO" >
3
+ <Appenders >
4
+ <Console name =" Console" target =" SYSTEM_OUT" >
5
+ <PatternLayout pattern =" %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
6
+ </Console >
7
+ </Appenders >
8
+ <Loggers >
9
+ <Root level =" debug" >
10
+ <AppenderRef ref =" Console" />
11
+ </Root >
12
+ </Loggers >
13
+ </Configuration >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <modelVersion >4.0.0</modelVersion >
6
+
7
+ <modules >
8
+ <module >console-captor-with-log4j-slf4j18</module >
9
+ </modules >
10
+
11
+ <parent >
12
+ <artifactId >java-tutorials</artifactId >
13
+ <groupId >io.github.hakky54</groupId >
14
+ <version >1.0.0-SNAPSHOT</version >
15
+ </parent >
16
+
17
+ <artifactId >console-captor-examples-parent</artifactId >
18
+ <version >1.0.0-SNAPSHOT</version >
19
+ <packaging >pom</packaging >
20
+
21
+ <dependencies >
22
+ <dependency >
23
+ <groupId >io.github.hakky54</groupId >
24
+ <artifactId >consolecaptor</artifactId >
25
+ <version >${version.consolecaptor} </version >
26
+ <scope >test</scope >
27
+ </dependency >
28
+
29
+ <dependency >
30
+ <groupId >org.junit.jupiter</groupId >
31
+ <artifactId >junit-jupiter-api</artifactId >
32
+ <version >${version.junit} </version >
33
+ <scope >test</scope >
34
+ </dependency >
35
+ <dependency >
36
+ <groupId >org.junit.jupiter</groupId >
37
+ <artifactId >junit-jupiter-engine</artifactId >
38
+ <version >${version.junit} </version >
39
+ <scope >test</scope >
40
+ </dependency >
41
+ <dependency >
42
+ <groupId >org.assertj</groupId >
43
+ <artifactId >assertj-core</artifactId >
44
+ <version >${version.assertj-core} </version >
45
+ <scope >test</scope >
46
+ </dependency >
47
+ </dependencies >
48
+
49
+ </project >
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 9
9
<module >log-captor-with-slf4j-logback-classic</module >
10
10
<module >log-captor-with-slf4j-log4j</module >
11
11
<module >log-captor-with-spring-boot-starter-log4j2</module >
12
- <module >log-captor-with-log4j-slf4j18</module >
13
12
</modules >
14
13
15
14
<parent >
Original file line number Diff line number Diff line change 19
19
<module >spring-cn-validation-with-aop</module >
20
20
<module >instant-server-ssl-reloading-with-vertx</module >
21
21
<module >instant-server-ssl-reloading-with-netty</module >
22
+ <module >console-captor-examples</module >
22
23
</modules >
23
24
24
25
<licenses >
You can’t perform that action at this time.
0 commit comments