Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to check since when AEM author/publisher instance is running?

Avatar

Level 2

I am new to AEM development.

I have use-case to check since how long AEM author/publish instance is up and running. Can you suggest how can I achieve this through Java/jsp?

Thanks,

1 Accepted Solution

Avatar

Correct answer by
Level 2

I am not sure if there is a function to get the directory. However, you can access the logs by just using the "crx-quickstart" when using the file path. For example: 

InputStream in = new FileInputStream(new File("crx-quickstart/logs/stdout.log"));

Here is an example component you could use to display the log file:

<%@include file="/libs/foundation/global.jsp"%> <%@page session="false" %> <%@ page import="java.util.*, java.io.*"%> <body> <% InputStream in = new FileInputStream(new File("crx-quickstart/logs/stdout.log")); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder out2 = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { out.append(line); } System.out.println(out2.toString());   //Prints the string content read from input stream reader.close(); %> </body>

If you make a component with this code, and add it to a page, it should output the file. It will be one big block of text, but the example should work.

View solution in original post

0 Replies

Avatar

Level 2

In order to check how long the the AEM author/publish instance has been up and running, you could use the stdout.txt log file that is located in your crx-quickstart folder under logs.

This log file records what time your instance of AEM started and what time it shuts down, and is refreshed every time the instance is started. You can read more about the log files here: http://docs.adobe.com/docs/en/cq/5-6/howto/logsaudits.html.

In order to achieve this through Java/jsp, you would need to read in the file, and search it for the following line - "Quickstart startup at (date goes here)".

Avatar

Level 2

You could also use JMX?

 

{   "Name": "Uptime",   "Value": "108473218",   "MBeanAttributeInfo": {   "Description": "Uptime",   "Readable": true,   "Writable": false,   "Is": false,   "Type": "long" }

Avatar

Level 2

swesto01 wrote...

In order to check how long the the AEM author/publish instance has been up and running, you could use the stdout.txt log file that is located in your crx-quickstart folder under logs.

This log file records what time your instance of AEM started and what time it shuts down, and is refreshed every time the instance is started. You can read more about the log files here: http://docs.adobe.com/docs/en/cq/5-6/howto/logsaudits.html.

In order to achieve this through Java/jsp, you would need to read in the file, and search it for the following line - "Quickstart startup at (date goes here)".

 

Thanks for your reply. 

How do I get base path of AEM Installation [to parse stdout.logs]? Different server will have different installation directory for AEM/CQ. Is there some function to get cq-installation-dir?

Thanks,

Avatar

Correct answer by
Level 2

I am not sure if there is a function to get the directory. However, you can access the logs by just using the "crx-quickstart" when using the file path. For example: 

InputStream in = new FileInputStream(new File("crx-quickstart/logs/stdout.log"));

Here is an example component you could use to display the log file:

<%@include file="/libs/foundation/global.jsp"%> <%@page session="false" %> <%@ page import="java.util.*, java.io.*"%> <body> <% InputStream in = new FileInputStream(new File("crx-quickstart/logs/stdout.log")); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder out2 = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { out.append(line); } System.out.println(out2.toString());   //Prints the string content read from input stream reader.close(); %> </body>

If you make a component with this code, and add it to a page, it should output the file. It will be one big block of text, but the example should work.

Avatar

Level 2

Thanks a lot! I can read stdout.log by using these relative path.