Expand my Community achievements bar.

Suggestions to capture GC log

Avatar

Level 2

Hi Team,

 

We are receiving CPU spike issues recently, so to troubleshoot we are planning to configure custom logger to capture gc.log. Could you please let us know some suggestions or class that captures gc.log, so that we can create loggers accordingly.

 

We need to capture under crx-quickstart/logs folder. Kindly let us know some suggestions to proceed further.

 

Thanks,

Aishwarya Karthikeyan

10 Replies

Avatar

Level 10

hi @AishwaryaKa

To capture Java Garbage Collection logs in your AEM environment, you generally configure JVM options to enable GC logging, as there isn't a specific Java class that "captures" GC logs that you can configure with a logger. 

From Java 9 onwards, GC logging is unified and uses the -Xlog option, for example:

-Xlog:gc*:file=crx-quickstart/logs/gc.log:time,uptime,level,tags:filecount=10,filesize=50M

 

Please refer to this page for further details.

Avatar

Level 2

Hi @giuseppebaglio,

Thanks for suggestion! Could you please let me know if it will work for AEM 6.5.22 as well.

Thanks & regards,

Aishwarya Karthikeyan

Avatar

Level 10

Yes, it will, but pay attention to the Java version used and utilize the proper command options, as mentioned in the article I shared above.

 

Avatar

Employee

Hello @AishwaryaKa 

Add JVM parameters to your AEM start script to capture GC logs:

>> For Java 8:
-Xloggc:crx-quickstart/logs/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps


>> For Java 11+:
-Xlog:gc*,gc+heap=debug,gc+pause=debug:file=crx-quickstart/logs/gc.log:time,uptime,level,tags:filecount=10,filesize=20M

File should be created under <AEM>/crx-quickstart/logs/gc.log

This should work for AEM 6.5.22.0

Avatar

Level 2

Hi @muskaanchandwani,

While updating the suggested jvm script in start file, we are unable to start the file. May i know whether any other suggestions on this is there to capture gc.log.

Thanks & regards,
Aishwarya karthikeyan

Avatar

Level 10

What command line did you use, and what error was displayed by the script?

You can try something like this:

export CQ_JVM_OPTS='-Xlog:gc*:file=crx-quickstart/logs/gc.log:time,uptime,level,tags:filecount=10,filesize=50M'
java $CQ_JVM_OPTS -jar aem-author-p4502.jar

Avatar

Employee

Hello @AishwaryaKa 

What is the Java version in use?

Java 11+ GC Parameters example :

-Xlog:gc*,gc+ref=debug,gc+heap=debug,gc+age=trace:file=/mnt/crx/author/crx-quickstart/logs/gc-%p-%t.log:tags,uptime,time,level:filecount=10,filesize=50m


(Don't use both -XX:+PrintGCDetails (Java 😎 and -Xlog:gc* (Java 11+) together)

 

Avatar

Level 2

Hi @muskaanchandwani ,

The java version we use currently in Java-11.

Avatar

Level 10

You can try one of these.

Basic logging:

-Xlog:gc*=info:file=/path/to/gc.log:time,uptime,level,tags

Detailed logging:

-Xlog:gc*=info,gc+phases=debug:file=/path/to/gc.log:time,uptime,level,tags

Complete debug-level logging:

-Xlog:gc*=debug:file=/path/to/gc.log:time,uptime,level,tags

 

 

Avatar

Employee

Hello @AishwaryaKa , thanks for confirming
could you please try below - 

1. Edit your AEM start script
Open:

crx-quickstart/bin/start

2. Add the Java 11 GC logging flag

(only -Xlog)

-Xlog:gc*,gc+ref=debug,gc+heap=debug,gc+age=trace:file=crx-quickstart/logs/gc-%p-%t.log:time,uptime,level,tags:filecount=10,filesize=50m

 

(Place it after your -Xms / -Xmx settings)

3. Avoid adding GC tuning parameters unless required - Only add the -Xlog parameter

4. Remove old Java 8 GC flags (if present)

Delete below flags:
-Xloggc
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCTimeStamps

5. Ensure directory exists & writable : crx-quickstart/logs/
6. Restart AEM