You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 6, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -302,6 +302,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-logging/tree/
| Native Image Logging Sample |[source code](https://github.com/googleapis/java-logging/blob/main/samples/native-image-sample/src/main/java/com/example/logging/NativeImageLoggingSample.java)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-logging&page=editor&open_in_editor=samples/native-image-sample/src/main/java/com/example/logging/NativeImageLoggingSample.java)|
305
306
| Get Sink Metadata |[source code](https://github.com/googleapis/java-logging/blob/main/samples/snippets/src/main/java/com/example/logging/GetSinkMetadata.java)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-logging&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/logging/GetSinkMetadata.java)|
306
307
| List Log Entries |[source code](https://github.com/googleapis/java-logging/blob/main/samples/snippets/src/main/java/com/example/logging/ListLogEntries.java)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-logging&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/logging/ListLogEntries.java)|
307
308
| List Logs |[source code](https://github.com/googleapis/java-logging/blob/main/samples/snippets/src/main/java/com/example/logging/ListLogs.java)|[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-logging&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/logging/ListLogs.java)|
# Cloud Logging Client Libraries with Native Image
2
+
3
+
This application uses the Google Cloud [Logging Client Libraries](https://github.com/googleapis/java-logging) and can be compiled with Native Image Native Image.
4
+
5
+
## Setup Instructions
6
+
7
+
You will need to follow these prerequisite steps in order to run the samples:
8
+
9
+
1. If you have not already, [create a Google Cloud Platform Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project).
10
+
11
+
2. Install the [Google Cloud SDK](https://cloud.google.com/sdk/) which will allow you to run the sample with your project's credentials.
12
+
13
+
Once installed, log in with Application Default Credentials using the following command:
14
+
15
+
```
16
+
gcloud auth application-default login
17
+
```
18
+
19
+
**Note:** Authenticating with Application Default Credentials is convenient to use during development, but we recommend [alternate methods of authentication](https://cloud.google.com/docs/authentication/production) during production use.
20
+
21
+
3. Install the GraalVM compiler.
22
+
23
+
You can follow the [official installation instructions](https://www.graalvm.org/docs/getting-started/#install-graalvm) from the GraalVM website.
24
+
After following the instructions, ensure that you install the native image extension installed by running:
25
+
26
+
```
27
+
gu install native-image
28
+
```
29
+
30
+
Once you finish following the instructions, verify that the default version of Java is set to the GraalVM version by running `java -version` in a terminal.
31
+
32
+
You will see something similar to the below output:
33
+
34
+
```
35
+
$ java -version
36
+
37
+
openjdk version "11.0.7" 2020-04-14
38
+
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
39
+
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)
40
+
```
41
+
42
+
4. Enable the [Logging APIs](https://console.cloud.google.com/flows/enableapi?apiid=logging.googleapis.com).
43
+
44
+
## Sample
45
+
46
+
Navigate to this directory in a new terminal.
47
+
48
+
1. Compile the application using the Native Image Compiler. This step may take a few minutes.
49
+
50
+
```
51
+
mvn package -P native -DskipTests
52
+
```
53
+
54
+
2. Run the application:
55
+
56
+
```
57
+
./target/native-image-sample
58
+
```
59
+
60
+
3. The application will log a message to your local terminal and to Google Cloud Console.
61
+
62
+
Navigate to the [Cloud Console Logs Viewer](https://console.cloud.google.com/logs/viewer) to view you logs and find the newly generated log entry in Cloud Console:
63
+
```
64
+
This is a log produced by Native Image.
65
+
```
66
+
### Sample Integration test with Native Image Support
67
+
In order to run the sample integration test as a native image, call the following command:
0 commit comments