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,
Solved! Go to Solution.
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.
You can use JMX to get the uptime. This [1] should help you on how to read JMX properties
[1] http://docs.adobe.com/docs/en/cq/5-6-1/developing/jmx-integration.html
Views
Replies
Total Likes
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)".
Views
Replies
Total Likes
You could also use JMX?
{ "Name": "Uptime", "Value": "108473218", "MBeanAttributeInfo": { "Description": "Uptime", "Readable": true, "Writable": false, "Is": false, "Type": "long" }
Views
Replies
Total Likes
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,
Views
Replies
Total Likes
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.
Thanks a lot! I can read stdout.log by using these relative path.
Views
Replies
Total Likes
Views
Likes
Replies