Skip to content

Commit be0debc

Browse files
authored
Merge pull request #7 from istvanballok/master
Support log4j2 2.7
2 parents 46ebeb6 + 7e2d66f commit be0debc

File tree

10 files changed

+31
-25
lines changed

10 files changed

+31
-25
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ This is a collection of support libraries for Java applications running on Cloud
66

77
When we say structured, we actually mean in JSON format. In that sense, it shares ideas with [logstash-logback-encoder](https://github.com/logstash/logstash-logback-encoder) (and a first internal version was actually based on it), but takes a simpler approach as we want to ensure that these structured messages adhere to standardized formats. With such standardized formats in place, it becomes much easier to ingest, process and search such messages in log analysis stacks like, e.g., [ELK](https://www.elastic.co/webinars/introduction-elk-stack).
88

9-
If you're interested in the specifications of these standardized formats, you may want to have closer look at the `fields.ml` files in the [beats folder](./cf-java-logging-support-core/beats).
9+
If you're interested in the specifications of these standardized formats, you may want to have closer look at the `fields.yml` files in the [beats folder](./cf-java-logging-support-core/beats).
1010

1111
While [logstash-logback-encoder](https://github.com/logstash/logstash-logback-encoder) is tied to [logback](http://logback.qos.ch/), we've tried to stay implementation neutral and have implemented the core functionality on top of [slf4j](http://www.slf4j.org/), but provide implementations for both [logback](http://logback.qos.ch/) and [log4j2](http://logging.apache.org/log4j/2.x/) (and we're open to contributions that would support other implementations).
1212

1313
The instrumentation part is currently focusing on providing [request filters for Java Servlets](http://www.oracle.com/technetwork/java/filters-137243.html) and [client and server filters for Jersey](https://jersey.java.net/documentation/latest/filters-and-interceptors.html), but again, we're open to contributions for other APIs and frameworks.
1414

1515
## Features and dependencies
1616

17-
As you can see from the structure of this repository, we're not providing one *uber* JAR that contains everything, but provide each feature separately. We also try to stay away from wiring up too many dependencies by tagging almost all of them as *provided.* As a consequence, it's your task to get all runtime dependencies resolved in your application POM file.
17+
As you can see from the structure of this repository, we're not providing one *uber* JAR that contains everything, but provide each feature separately. We also try to stay away from wiring up too many dependencies by tagging almost all of them as *provided.* As a consequence, it's your task to get all runtime dependencies resolved in your application POM file.
1818

1919
All in all, you should do the following:
2020

21-
* make up your mind which features you actually need,
22-
* adjust your Maven dependencies accordingly,
21+
* make up your mind which features you actually need,
22+
* adjust your Maven dependencies accordingly,
2323
* pick your favorite logging implementation, and
2424
* adjust your logging configuration accordingly.
2525

@@ -39,7 +39,7 @@ This feature only depends on the servlet API which you have included in your POM
3939

4040
The *core* feature (on which all other features rely) is just using the `org.slf4j` API, but to actually get logs written, you need to pick an implementation feature. As stated above, we have two implementations
4141

42-
* `cf-java-logging-support-logback` based on [logback](http://logback.qos.ch/), and
42+
* `cf-java-logging-support-logback` based on [logback](http://logback.qos.ch/), and
4343
* `cf-java-logging-support-log4j2` based on [log4j2](http://logging.apache.org/log4j/2.x/).
4444

4545
Again, we don't include dependencies to those implementation backends ourselves, so you need to provide the corresponding dependencies in your POM file:
@@ -91,7 +91,7 @@ Here are sort of the minimal configurations you'd need:
9191
<appender name="STDOUT-JSON" class="ch.qos.logback.core.ConsoleAppender">
9292
<encoder class="com.sap.hcp.cf.logback.encoder.JsonEncoder"/>
9393
</appender>
94-
<!-- for local development, you may want to switch to a more human-readable layout -->
94+
<!-- for local development, you may want to switch to a more human-readable layout -->
9595
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
9696
<encoder>
9797
<pattern>%date %-5level [%thread] - [%logger] [%mdc] - %msg%n</pattern>
@@ -102,14 +102,14 @@ Here are sort of the minimal configurations you'd need:
102102
<appender-ref ref="STDOUT-JSON" />
103103
</root>
104104
<!-- request metrics are reported using INFO level, so make sure the instrumentation loggers are set to that level -->
105-
<logger name="com.sap.hcp.cf" level="INFO" />
105+
<logger name="com.sap.hcp.cf" level="INFO" />
106106
</configuration>
107107
```
108108

109109
*log4j2.xml:*
110110

111111
``` xml
112-
<Configuration
112+
<Configuration
113113
status="warn" strict="true"
114114
packages="com.sap.hcp.cf.log4j2.converter,com.sap.hcp.cf.log4j2.layout">
115115
<Appenders>
@@ -128,7 +128,7 @@ Here are sort of the minimal configurations you'd need:
128128
<!-- request metrics are reported using INFO level, so make sure the instrumentation loggers are set to that level -->
129129
<Logger name="com.sap.hcp.cf" level="INFO"/>
130130
</Loggers>
131-
</Configuration>
131+
</Configuration>
132132
```
133133

134134
## Sample Application

cf-java-logging-support-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<parent>
2525
<groupId>com.sap.hcp.cf.logging</groupId>
2626
<artifactId>cf-java-logging-support-parent</artifactId>
27-
<version>2.0.9</version>
27+
<version>2.0.10</version>
2828
<relativePath>../pom.xml</relativePath>
2929
</parent>
3030
<profiles>

cf-java-logging-support-jersey/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<relativePath>../pom.xml</relativePath>
1010
<groupId>com.sap.hcp.cf.logging</groupId>
1111
<artifactId>cf-java-logging-support-parent</artifactId>
12-
<version>2.0.9</version>
12+
<version>2.0.10</version>
1313
</parent>
1414

1515
<name>cf-java-logging-support-jersey</name>

cf-java-logging-support-log4j2/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
<relativePath>../pom.xml</relativePath>
1212
<groupId>com.sap.hcp.cf.logging</groupId>
1313
<artifactId>cf-java-logging-support-parent</artifactId>
14-
<version>2.0.9</version>
14+
<version>2.0.10</version>
1515
</parent>
1616

1717
<properties>
18-
<log4j2.version>2.4.1</log4j2.version>
18+
<log4j2.version>2.7</log4j2.version>
1919
</properties>
2020

2121
<dependencies>

cf-java-logging-support-log4j2/src/test/java/com/sap/hcp/cf/logging/common/AbstractTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,21 @@ public abstract class AbstractTest {
2020

2121
protected final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
2222
protected final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
23+
private PrintStream stdout;
24+
private PrintStream stderr;
25+
2326
@Before
2427
public void setupStreams() {
28+
stdout = System.out;
29+
stderr = System.err;
2530
System.setOut(new PrintStream(outContent));
2631
System.setErr(new PrintStream(errContent));
2732
}
2833

2934
@After
3035
public void teardownStreams() {
31-
System.setOut(null);
32-
System.setErr(null);
36+
System.setOut(stdout);
37+
System.setErr(stderr);
3338
}
3439
protected String getMessage() {
3540
return getField("msg");

cf-java-logging-support-logback/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<relativePath>../pom.xml</relativePath>
1111
<groupId>com.sap.hcp.cf.logging</groupId>
1212
<artifactId>cf-java-logging-support-parent</artifactId>
13-
<version>2.0.9</version>
13+
<version>2.0.10</version>
1414
</parent>
1515

1616
<properties>

cf-java-logging-support-servlet/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>com.sap.hcp.cf.logging</groupId>
1111
<artifactId>cf-java-logging-support-parent</artifactId>
12-
<version>2.0.9</version>
12+
<version>2.0.10</version>
1313
<relativePath>../pom.xml</relativePath>
1414
</parent>
1515

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.sap.hcp.cf.logging</groupId>
66
<artifactId>cf-java-logging-support-parent</artifactId>
7-
<version>2.0.9</version>
7+
<version>2.0.10</version>
88
<packaging>pom</packaging>
99

1010
<name>Cloud Foundry Java logging support components</name>

sample/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ applications:
77
host: logging-sample-app
88
instances: 1
99
memory: 256M
10-
path: target/logging-sample-app-2.0.9.war
10+
path: target/logging-sample-app-2.0.10.war

sample/pom.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
<parent>
77
<groupId>com.sap.hcp.cf.logging</groupId>
88
<artifactId>cf-java-logging-support-parent</artifactId>
9-
<version>2.0.9</version>
9+
<version>2.0.10</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

1313
<properties>
1414
<tomcat.version>7.0.65</tomcat.version>
15-
<log4j2.version>2.4.1</log4j2.version>
15+
<log4j2.version>2.7</log4j2.version>
1616
<logback.version>1.1.3</logback.version>
1717
<jackson.version>2.5.4</jackson.version>
1818
<slf4j.version>1.7.12</slf4j.version>
1919
<jersey.version>2.22.2</jersey.version>
2020
<javax.ws.version>2.0.1</javax.ws.version>
21+
<cf-logging.version>2.0.10</cf-logging.version>
2122
</properties>
2223
<dependencies>
2324
<dependency>
@@ -78,10 +79,10 @@
7879

7980
<!-- LOG4J2 VERSION
8081
81-
<dependency>
82-
<groupId>com.sap.hcp.cf-logging.logging</groupId>
83-
<artifactId>java-logging-support-log4j2</artifactId>
84-
<version>${cf-logging.version}</version>
82+
<dependency>
83+
<groupId>com.sap.hcp.cf.logging</groupId>
84+
<artifactId>cf-java-logging-support-log4j2</artifactId>
85+
<version>${cf-logging.version}</version>
8586
</dependency>
8687
<dependency>
8788
<groupId>org.apache.logging.log4j</groupId>

0 commit comments

Comments
 (0)