My application constructs a lot of logs every day. Java application to store these data into file or open a new external window., I cannot have a real time analysis. So what optimization can be done to get a real time analysis?
Asked
Active
Viewed 1,518 times
0
-
Do you mean a manual analysis? Please precise your question so that we can help you. – xav Mar 25 '14 at 23:21
-
For ex: I am executing the jenkins CI build. In every build we can see the execution logs, those logs displayed with few delay. I need those logs to be generate in new window without any delay (real time logs) The live and actual logs from the every single line of execution should be logged in console. Whenever the user triggering a build, Each and every action should monitor and produce the log. – Khalith Basha Mar 25 '14 at 23:51
2 Answers
0
How about logging to files instead of to the console? If you use a RollingFileAppender you can configure log4j to create a new file every hour or every 10 minutes. Using the RoutingAppender you should be able to create a new file for very build (see the log4j2 FAQ page for an example).

Remko Popma
- 35,130
- 11
- 92
- 114
-
how to print log4j's logs in cmd. Full exeuction log should in cmd console – Khalith Basha Mar 26 '14 at 19:00
-
You can view the file in real time in the cmd console with a tool like tail. I don't see how Log4j would be able to direct its output to multiple console windows (each of which are different processes) otherwise. – Remko Popma Mar 26 '14 at 23:32
0
u can use log4j or log4j2 am just providing an xml for log4j xml based appender Structure here
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="NORMAL_LOG_FILE" class="org.apache.log4j.DailyRollingFileAppender">
<errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler" />
<param name="File" value="C://LOGS/app.log" />
<param name="Append" value="true" />
<param name="Threshold" value="INFO" />
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p %c{3}:%L %m\n" />
</layout>
</appender>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler" />
<param name="Target" value="System.out" />
<param name="Threshold" value="INFO" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c{1}:%L %m\n" />
</layout>
</appender>
<logger name="com.test" additivity="false">
<level value="ALL" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="NORMAL_LOG_FILE" />
<appender-ref ref="ERR_LOG_FILE" />
</logger>
<logger name="com.test" additivity="false">
<level value="INFO" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="NORMAL_LOG_FILE" />
<appender-ref ref="ERR_LOG_FILE" />
</logger>
<root>
<appender-ref ref="CONSOLE" />
<appender-ref ref="NORMAL_LOG_FILE" />
</root>
</log4j:configuration>

SUBZ
- 139
- 1
- 7
-
u can use log4j or log4j2 am just providing an xml for log4j xml based appender Structure here – SUBZ Mar 26 '14 at 10:20
-
how to print log4j's logs in cmd. Full exeuction log should in cmd console – Khalith Basha Mar 26 '14 at 18:59
-
i already added appender for console if you r running your app in tomcat or any other container you can tail catalina .out directly – SUBZ Mar 27 '14 at 07:54
-
Could you pls suggest me on tail. I am new to tomcat. I am running my app in tomcat and I am able to append the log in abc.out file. Further could you pls help me on this. – Khalith Basha Mar 27 '14 at 17:34
-
in log4j specify the log path in linux based system go to current directory ...of logs>>>>>>>>> >>>>>>>> then `tail -f catalina.out` in windows based system open catalina.out in your console – SUBZ Mar 28 '14 at 06:02