有興趣的話可以看一下之前的筆記: [Java] 快快樂樂學會log4j
Appender
提供以下幾種AppenderAppender
AlertAppender =>將log透過alert秀出來
AjaxAppender => 將log寫到Server存起來
PopUpAppender
InPageAppender
BrowserConsoleAppender => 將log印在console上
Level
提供以下的log等級設定
log4javascript.Level.ALL
log4javascript.Level.TRACE
log4javascript.Level.DEBUG
log4javascript.Level.INFO
log4javascript.Level.WARN
log4javascript.Level.ERROR
log4javascript.Level.FATAL
log4javascript.Level.OFF
Pattern Layout
提供以下語法供使用者客製化layout的輸出
onversion Character | Effect |
---|---|
a | Outputs log messages specified as an array. Behaves exactly like %m , except that multiple log messages are assumed to have been specified in the logging call as an array rather than as multiple parameters.Since: 1.4 |
c | Outputs the logger name. |
d | Outputs 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 is the same as that used by Java's SimpleDateFormat . log4javascript includes a full implementation of SimpleDateFormat's format method, with the exception of the pattern letter 'z', (string representation of the timezone) for which the information is not available in JavaScript. |
f | Outputs the value of a custom field set on the layout. If present, the specifier gives the index in the array of custom fields to use; otherwise, the first custom field in the array is used. Since: 1.3 |
m | Outputs the log messages of the logging event (i.e. the log messages supplied by the client code). As of version 1.4, multiple log messages may be supplied to logging calls. %m displays each log message (using the rules below) one after another, separated by spaces.As of version 1.3, an object may be specified as the log message and will be expanded to show its properties in the output, provided that a specifier containing the number of levels to expand is provided. If no specifier is provided then the message will be treated as a string regardless of its type. For example, %m{1} will display an expansion of the object one level deep, i.e. each property of the object will be displayed but if the property value is itself an object it will not be expanded and will appear as [object Object] . |
n | Outputs a line separator. |
p | Outputs the level of the logging event. |
r | Outputs the number of milliseconds since log4javascript was initialized. |
% | The sequence %% outputs a single percent sign. |
範例
簡單的操作方法請參考以下的gisthttps://gist.githubusercontent.com/iambigd/373cbcbab4a31bb73163/raw/86b1c542859bd85df4032b5055cf4f25b35b683e/gistfile1.html
沒有留言:
張貼留言
留個話吧:)