Google Website Translator Gadget

sábado, 24 de marzo de 2012

Apache log4j 1.2 - Pattern Layout

http://logging.apache.org/log4j/1.2/
Un de les coses que més amoinen es la publicació dels errors i amb log4j es possible, però a més permet cert control sobre el format de publicació.
Encara que normalment la majoria de gent no perd el temps i còpia un format, el pots consultar aquí o a la pàgina original log4j 1.2 PatternLayout



Examples:
%r [%t] %-5p %c %x - %m%n
%-6r [%15.15t] %-5p %30.30c %x - %m%n
%-4r [%t] %-5p %c %x - %m%n.

%rUsed to output the number of milliseconds elapsed from the construction of the layout until the creation of the logging event.
%tUsed to output the name of the thread that generated the logging event.
%pUsed to output the priority of the logging event.
%cUsed to output the category of the logging event.
%xUsed to output the NDC (nested diagnostic context) associated with the thread that generated the logging event.
%X{key}Used to output the MDC (mapped diagnostic context) associated with the thread that generated the logging event for specified key
%mUsed to output the application supplied message associated with the logging event.
%MUsed to output the method name where the logging request was issued.
%nUsed to output the platform-specific newline character or characters.
%CUsed to output the fully qualified class name of the caller issuing the logging request. For example, for the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass".
%dDate 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.
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}.
%FUsed to output the file name where the logging request was issued.
%lUsed to output location information of the caller which generated the logging event, usually consists of the fully qualified name of the calling method followed by the callers source the file name and line number between parentheses. Note:its generation is extremely slow and should be avoided unless execution speed is not an issue.
%LUsed to output the line number from where the logging request was issued.
-- left justification flag

Enllaços relacionats:

Log4j: Crear un fitxer de sortida
Appache Log4j: API Appender



No hay comentarios:

Publicar un comentario