@@ -11,6 +11,141 @@ Logging provides an opinionated logger with output structured as JSON.
1111* Log Lambda event when instructed, disabled by default, can be enabled explicitly via annotation param
1212* Append additional keys to structured log at any point in time
1313
14+ ## Install
15+
16+ Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes.
17+
18+ === "Maven Java 11+"
19+
20+ ```xml hl_lines="3-7 16 18 24-27"
21+ <dependencies>
22+ ...
23+ <dependency>
24+ <groupId>software.amazon.lambda</groupId>
25+ <artifactId>powertools-logging</artifactId>
26+ <version>{{ powertools.version }}</version>
27+ </dependency>
28+ ...
29+ </dependencies>
30+ ...
31+ <!-- configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project -->
32+ <build>
33+ <plugins>
34+ ...
35+ <plugin>
36+ <groupId>dev.aspectj</groupId>
37+ <artifactId>aspectj-maven-plugin</artifactId>
38+ <version>1.13.1</version>
39+ <configuration>
40+ <source>11</source> <!-- or higher -->
41+ <target>11</target> <!-- or higher -->
42+ <complianceLevel>11</complianceLevel> <!-- or higher -->
43+ <aspectLibraries>
44+ <aspectLibrary>
45+ <groupId>software.amazon.lambda</groupId>
46+ <artifactId>powertools-logging</artifactId>
47+ </aspectLibrary>
48+ </aspectLibraries>
49+ </configuration>
50+ <executions>
51+ <execution>
52+ <goals>
53+ <goal>compile</goal>
54+ </goals>
55+ </execution>
56+ </executions>
57+ </plugin>
58+ ...
59+ </plugins>
60+ </build>
61+ ```
62+
63+ === "Maven Java 1.8"
64+
65+ ```xml hl_lines="3-7 16 18 24-27"
66+ <dependencies>
67+ ...
68+ <dependency>
69+ <groupId>software.amazon.lambda</groupId>
70+ <artifactId>powertools-logging</artifactId>
71+ <version>{{ powertools.version }}</version>
72+ </dependency>
73+ ...
74+ </dependencies>
75+ ...
76+ <!-- configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project -->
77+ <build>
78+ <plugins>
79+ ...
80+ <plugin>
81+ <groupId>org.codehaus.mojo</groupId>
82+ <artifactId>aspectj-maven-plugin</artifactId>
83+ <version>1.14.0</version>
84+ <configuration>
85+ <source>1.8</source>
86+ <target>1.8</target>
87+ <complianceLevel>1.8</complianceLevel>
88+ <aspectLibraries>
89+ <aspectLibrary>
90+ <groupId>software.amazon.lambda</groupId>
91+ <artifactId>powertools-logging</artifactId>
92+ </aspectLibrary>
93+ </aspectLibraries>
94+ </configuration>
95+ <executions>
96+ <execution>
97+ <goals>
98+ <goal>compile</goal>
99+ </goals>
100+ </execution>
101+ </executions>
102+ </plugin>
103+ ...
104+ </plugins>
105+ </build>
106+ ```
107+
108+ === "Gradle Java 11+"
109+
110+ ```groovy hl_lines="3 11"
111+ plugins {
112+ id 'java'
113+ id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0'
114+ }
115+
116+ repositories {
117+ mavenCentral()
118+ }
119+
120+ dependencies {
121+ aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}'
122+ }
123+
124+ sourceCompatibility = 11
125+ targetCompatibility = 11
126+ ```
127+
128+ === "Gradle Java 1.8"
129+
130+ ```groovy hl_lines="3 11"
131+ plugins {
132+ id 'java'
133+ id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3'
134+ }
135+
136+ repositories {
137+ mavenCentral()
138+ }
139+
140+ dependencies {
141+ aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}'
142+ }
143+
144+ sourceCompatibility = 1.8
145+ targetCompatibility = 1.8
146+ ```
147+
148+
14149## Initialization
15150
16151Powertools for AWS Lambda (Java) extends the functionality of Log4J. Below is an example ` #!xml log4j2.xml ` file, with the ` JsonTemplateLayout ` using ` #!json LambdaJsonLayout.json ` configured.
0 commit comments