Skip to content

Commit b9abd1b

Browse files
committed
java log4j 1.1.0 - use LambdaLogger method added to com.amazonaws:aws-lambda-java-core:1.2.0
1 parent 36747fc commit b9abd1b

File tree

2 files changed

+141
-144
lines changed

2 files changed

+141
-144
lines changed

aws-lambda-java-log4j2/pom.xml

+136-136
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,141 @@
11
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
2-
<modelVersion>4.0.0</modelVersion>
2+
<modelVersion>4.0.0</modelVersion>
33

4-
<groupId>com.amazonaws</groupId>
5-
<artifactId>aws-lambda-java-log4j2</artifactId>
6-
<version>1.0.0</version>
7-
<packaging>jar</packaging>
4+
<groupId>com.amazonaws</groupId>
5+
<artifactId>aws-lambda-java-log4j2</artifactId>
6+
<version>1.1.0</version>
7+
<packaging>jar</packaging>
88

9-
<name>AWS Lambda Java Log4j 2.8 Libraries</name>
10-
<description>
11-
Support for using log4j 2.8 with AWS Lambda.
12-
</description>
13-
<url>https://aws.amazon.com/lambda/</url>
14-
<licenses>
15-
<license>
16-
<name>Apache License, Version 2.0</name>
17-
<url>https://aws.amazon.com/apache2.0</url>
18-
<distribution>repo</distribution>
19-
</license>
20-
</licenses>
21-
<scm>
22-
<url>https://github.com/aws/aws-lambda-java-libs.git</url>
23-
</scm>
24-
<developers>
25-
<developer>
26-
<name>AWS Lambda team</name>
27-
<organization>Amazon Web Services</organization>
28-
<organizationUrl>https://aws.amazon.com/</organizationUrl>
29-
</developer>
30-
</developers>
31-
<dependencies>
32-
<dependency>
33-
<groupId>com.amazonaws</groupId>
34-
<artifactId>aws-lambda-java-core</artifactId>
35-
<version>1.1.0</version>
36-
</dependency>
37-
<dependency>
38-
<groupId>org.apache.logging.log4j</groupId>
39-
<artifactId>log4j-core</artifactId>
40-
<version>2.8.2</version>
41-
</dependency>
42-
<dependency>
43-
<groupId>org.apache.logging.log4j</groupId>
44-
<artifactId>log4j-api</artifactId>
45-
<version>2.8.2</version>
46-
</dependency>
47-
</dependencies>
48-
<distributionManagement>
49-
<repository>
50-
<id>sonatype-nexus-staging</id>
51-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
52-
</repository>
53-
</distributionManagement>
9+
<name>AWS Lambda Java Log4j 2.8 Libraries</name>
10+
<description>
11+
Support for using log4j 2.8 with AWS Lambda.
12+
</description>
13+
<url>https://aws.amazon.com/lambda/</url>
14+
<licenses>
15+
<license>
16+
<name>Apache License, Version 2.0</name>
17+
<url>https://aws.amazon.com/apache2.0</url>
18+
<distribution>repo</distribution>
19+
</license>
20+
</licenses>
21+
<scm>
22+
<url>https://github.com/aws/aws-lambda-java-libs.git</url>
23+
</scm>
24+
<developers>
25+
<developer>
26+
<name>AWS Lambda team</name>
27+
<organization>Amazon Web Services</organization>
28+
<organizationUrl>https://aws.amazon.com/</organizationUrl>
29+
</developer>
30+
</developers>
31+
<dependencies>
32+
<dependency>
33+
<groupId>com.amazonaws</groupId>
34+
<artifactId>aws-lambda-java-core</artifactId>
35+
<version>1.2.0</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.apache.logging.log4j</groupId>
39+
<artifactId>log4j-core</artifactId>
40+
<version>2.8.2</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.apache.logging.log4j</groupId>
44+
<artifactId>log4j-api</artifactId>
45+
<version>2.8.2</version>
46+
</dependency>
47+
</dependencies>
48+
<distributionManagement>
49+
<repository>
50+
<id>sonatype-nexus-staging</id>
51+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
52+
</repository>
53+
</distributionManagement>
5454

55-
<profiles>
56-
<profile>
57-
<id>dev</id>
58-
<build>
59-
<plugins>
60-
<plugin>
61-
<groupId>org.apache.maven.plugins</groupId>
62-
<artifactId>maven-javadoc-plugin</artifactId>
63-
<version>2.9.1</version>
64-
<configuration>
65-
<additionalparam>-Xdoclint:none</additionalparam>
66-
</configuration>
67-
<executions>
68-
<execution>
69-
<id>attach-javadocs</id>
70-
<goals>
71-
<goal>jar</goal>
72-
</goals>
73-
</execution>
74-
</executions>
75-
</plugin>
76-
</plugins>
77-
</build>
78-
</profile>
79-
<profile>
80-
<id>release</id>
81-
<build>
82-
<plugins>
83-
<plugin>
84-
<groupId>org.apache.maven.plugins</groupId>
85-
<artifactId>maven-source-plugin</artifactId>
86-
<version>2.2.1</version>
87-
<executions>
88-
<execution>
89-
<id>attach-sources</id>
90-
<goals>
91-
<goal>jar-no-fork</goal>
92-
</goals>
93-
</execution>
94-
</executions>
95-
</plugin>
96-
<plugin>
97-
<groupId>org.apache.maven.plugins</groupId>
98-
<artifactId>maven-javadoc-plugin</artifactId>
99-
<version>2.9.1</version>
100-
<configuration>
101-
<additionalparam>-Xdoclint:none</additionalparam>
102-
</configuration>
103-
<executions>
104-
<execution>
105-
<id>attach-javadocs</id>
106-
<goals>
107-
<goal>jar</goal>
108-
</goals>
109-
</execution>
110-
</executions>
111-
</plugin>
112-
<plugin>
113-
<groupId>org.apache.maven.plugins</groupId>
114-
<artifactId>maven-gpg-plugin</artifactId>
115-
<version>1.5</version>
116-
<executions>
117-
<execution>
118-
<id>sign-artifacts</id>
119-
<phase>verify</phase>
120-
<goals>
121-
<goal>sign</goal>
122-
</goals>
123-
</execution>
124-
</executions>
125-
</plugin>
126-
<plugin>
127-
<groupId>org.sonatype.plugins</groupId>
128-
<artifactId>nexus-staging-maven-plugin</artifactId>
129-
<version>1.6.3</version>
130-
<extensions>true</extensions>
131-
<configuration>
132-
<serverId>sonatype-nexus-staging</serverId>
133-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
134-
<autoReleaseAfterClose>false</autoReleaseAfterClose>
135-
</configuration>
136-
</plugin>
137-
</plugins>
138-
</build>
139-
</profile>
140-
</profiles>
55+
<profiles>
56+
<profile>
57+
<id>dev</id>
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-javadoc-plugin</artifactId>
63+
<version>2.9.1</version>
64+
<configuration>
65+
<additionalparam>-Xdoclint:none</additionalparam>
66+
</configuration>
67+
<executions>
68+
<execution>
69+
<id>attach-javadocs</id>
70+
<goals>
71+
<goal>jar</goal>
72+
</goals>
73+
</execution>
74+
</executions>
75+
</plugin>
76+
</plugins>
77+
</build>
78+
</profile>
79+
<profile>
80+
<id>release</id>
81+
<build>
82+
<plugins>
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-source-plugin</artifactId>
86+
<version>2.2.1</version>
87+
<executions>
88+
<execution>
89+
<id>attach-sources</id>
90+
<goals>
91+
<goal>jar-no-fork</goal>
92+
</goals>
93+
</execution>
94+
</executions>
95+
</plugin>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-javadoc-plugin</artifactId>
99+
<version>2.9.1</version>
100+
<configuration>
101+
<additionalparam>-Xdoclint:none</additionalparam>
102+
</configuration>
103+
<executions>
104+
<execution>
105+
<id>attach-javadocs</id>
106+
<goals>
107+
<goal>jar</goal>
108+
</goals>
109+
</execution>
110+
</executions>
111+
</plugin>
112+
<plugin>
113+
<groupId>org.apache.maven.plugins</groupId>
114+
<artifactId>maven-gpg-plugin</artifactId>
115+
<version>1.5</version>
116+
<executions>
117+
<execution>
118+
<id>sign-artifacts</id>
119+
<phase>verify</phase>
120+
<goals>
121+
<goal>sign</goal>
122+
</goals>
123+
</execution>
124+
</executions>
125+
</plugin>
126+
<plugin>
127+
<groupId>org.sonatype.plugins</groupId>
128+
<artifactId>nexus-staging-maven-plugin</artifactId>
129+
<version>1.6.3</version>
130+
<extensions>true</extensions>
131+
<configuration>
132+
<serverId>sonatype-nexus-staging</serverId>
133+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
134+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
135+
</configuration>
136+
</plugin>
137+
</plugins>
138+
</build>
139+
</profile>
140+
</profiles>
141141
</project>

aws-lambda-java-log4j2/src/main/java/com/amazonaws/services/lambda/runtime/log4j2/LambdaAppender.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.amazonaws.services.lambda.runtime.log4j2;
22

3+
import com.amazonaws.services.lambda.runtime.LambdaRuntime;
34
import com.amazonaws.services.lambda.runtime.LambdaRuntimeInternal;
5+
import com.amazonaws.services.lambda.runtime.LambdaLogger;
46

57
import org.apache.logging.log4j.core.Filter;
68
import org.apache.logging.log4j.core.Layout;
@@ -9,7 +11,6 @@
911
import org.apache.logging.log4j.core.config.plugins.Plugin;
1012
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
1113

12-
import java.io.IOException;
1314
import java.io.Serializable;
1415

1516
/**
@@ -24,6 +25,8 @@ public class LambdaAppender extends AbstractAppender {
2425
public static final String PLUGIN_CATEGORY = "Core";
2526
public static final String PLUGIN_TYPE = "appender";
2627

28+
private LambdaLogger logger = LambdaRuntime.getLogger();
29+
2730
/**
2831
* Builder class that follows log4j2 plugin convention
2932
* @param <B> Generic Builder class
@@ -68,12 +71,6 @@ private LambdaAppender(String name, Filter filter, Layout<? extends Serializable
6871
* @param event log4j event
6972
*/
7073
public void append(LogEvent event) {
71-
try {
72-
System.out.write(super.getLayout().toByteArray(event));
73-
System.out.flush();
74-
System.out.print(System.lineSeparator());
75-
} catch (IOException e) {
76-
e.printStackTrace();
77-
}
74+
logger.log(super.getLayout().toByteArray(event));
7875
}
7976
}

0 commit comments

Comments
 (0)