Apache log4j (Ver 1.2)
Background
The Log4j Analysis App presents a predefined set of dashboards and gadgets visualizing log4j logs. The Log4j analysis pack addresses the need to manage and debug Java applications and infrastructure during development, testing, and production. The App helps measure, troubleshoot, and optimize Java based applications with visualization and investigation dashboards.
Steps
- Add Log Data In XpoLog, When adding a log to XpoLog you can now select the Log Type (logtype) for Apache log4j the are the following logtypes:
- log4j
- Once all required information is set click next and edit the log pattern, this step is crucial to the accuracy and deployment of the App. Use the following conversion table to build the XpoLog pattern out of the log4j log format.
Â
Example
In the Apache Log4J configuration file, can be either properties files, XML file, or in some case the log format was created programmatically for which you can manually create the pattern for the data.
log4j.appender.xpolog.layout.ConversionPattern=[%d] [%t] [%p] [%c] [%l] %m%n
The following sequence is the log structure definition for the log4j log [%d] [%t] [%p] [%c] [%l] %m%n
In XpoLog such pattern will be translated into:
for more information see below:
[{date:Date,locale=en,yyyy-MM-dd HH:mm:ss,SSS}] [{text:Thread,ftype=thread}] [{priority:Priority,ftype=severity;,DEBUG;INFO;WARNING;ERROR;FATAL}] [{string:Class,ftype=class}] [{string:Method,ftype=method}({text:Source,ftype=sourcecode}:{number:LineNumber,ftype=linenumber})] {string:Message,ftype=message}
Apache Log4j Conversion Table
logtyep should be set to:Â log4j
 |  |  |  |
---|---|---|---|
%c | Used to output the category of the logging event. The category conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets. If a precision specifier is given, then only the corresponding number of right most components of the category name will be printed. By default the category name is printed in full. For example, for the category name "a.b.c" the pattern %c{2} will output "b.c". | {text:Class,ftype=class} |  |
%C | Used to output the fully qualified class name of the caller issuing the logging request. This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets. If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed. By default the class name is output in fully qualified form. For example, for the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass". WARNING Generating the caller class information is slow. Thus, use should be avoided unless execution speed is not an issue. | {text:Class,ftype=class} |  |
%d %d{date pattenrn} %d{ISO8601} %d{ABSOLUTE} | Used to output the date of the logging event. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example,  %d{HH:mm:ss,SSS} or %d{dd MMM yyyy HH:mm:ss,SSS}. If no date format specifier is given then ISO8601 format is assumed. The date format specifier admits the same syntax as the time pattern string of the SimpleDateFormat. Although part of the standard JDK, the performance of SimpleDateFormat is quite poor. For better results it is recommended to use the log4j date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying AbsoluteTimeDateFormat, DateTimeDateFormat and respectively ISO8601DateFormat. For example, %d{ISO8601} or %d{ABSOLUTE}. These dedicated date formatters perform significantly better than SimpleDateFormat. | {date:Date,locale=<?>,yyyy-MM-dd HH:mm:ss,SSS} Note: (use default locale) {date:Date,locale=<?>,<same pattern>} {date:Date,locale=<?>,yyyy-MM-dd HH:mm:ss,SSS} Note: (use default locale) |  |
%F | Used to output the file name where the logging request was issued. WARNINGÂ Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue. | {text:Class,ftype=class} | Â |
%l | Used to output location information of the caller which generated the logging event. The location information depends on the JVM implementation but usually consists of the fully qualified name of the calling method followed by the callers source the file name and line number between parentheses. The location information can be very useful. However, its generation is extremely slow and should be avoided unless execution speed is not an issue. | {text:Method,ftype=method}({text:Class,ftype=sourcecode}:{number:LineNumber,ftype=linenumber}) |  |
%L | Used to output the line number from where the logging request was issued. WARNINGÂ Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue. | {number:LineNumber,ftype=linenumber} | Â |
%m | Used to output the application supplied message associated with the logging event. | {string:Message,ftype=message} | Â |
%M | Used to output the method name where the logging request was issued. WARNINGÂ Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue. | {text:MethodName,ftype=method} | Â |
%n | Outputs the platform dependent line separator character or characters. This conversion character offers practically the same performance as using non-portable line separator strings such as "\n", or "\r\n". Thus, it is the preferred way of specifying a line separator. | {eol} | Â |
%p | Used to output the priority of the logging event. | {priority:Priority,ALL;TRACE;DEBUG;INFO;WARN;ERROR;FATAL,ftype=severity} | Â |
%r | Used to output the number of milliseconds elapsed from the construction of the layout until the creation of the logging event. | {number:LogSpeed,ftype=logprocesstimemilli} | Â |
%t | Used to output the name of the thread that generated the logging event. | {string:Thread,ftype=thread} | Â |
x | Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event. | Â | Â |
X | Used to output the MDC (mapped diagnostic context) associated with the thread that generated the logging event. The X conversion character must be followed by the key for the map placed between braces, as in %X{clientNumber} where clientNumber is the key. The value in the MDC corresponding to the key will be output. See MDC class for more details. |  |  |
% | The sequence %% outputs a single percent sign. | N\A | Â |
 |  |  |  |