public class LogcatAppender extends AppenderBase<ILoggingEvent>
Note:
By default, this appender pushes all messages to logcat regardless
of logcat's own filter settings (i.e., everything is printed). To disable this
behavior and enable filter-checking, use setCheckLoggable(boolean)
.
See the Android Developer Guide for details on adjusting the logcat filter.
See http://developer.android.com/guide/developing/tools/adb.html#filteringoutput
name, started
context
Constructor and Description |
---|
LogcatAppender()
As in most cases, the default constructor does nothing.
|
Modifier and Type | Method and Description |
---|---|
void |
append(ILoggingEvent event)
Writes an event to Android's logging mechanism (logcat)
|
boolean |
getCheckLoggable()
Gets the enable status of the
isLoggable() -check
that is called before logging |
PatternLayoutEncoder |
getEncoder()
Gets the pattern-layout encoder for this appender's logcat message
|
protected String |
getTag(ILoggingEvent event)
Gets the logcat tag string of a logging event
|
PatternLayoutEncoder |
getTagEncoder()
Gets the pattern-layout encoder for this appender's logcat tag
|
void |
setCheckLoggable(boolean enable)
Sets whether to ask Android before logging a message with a specific
tag and priority (i.e., calls
android.util.Log.html#isLoggable ). |
void |
setEncoder(PatternLayoutEncoder encoder)
Sets the pattern-layout encoder for this appender's logcat message
|
void |
setTagEncoder(PatternLayoutEncoder encoder)
Sets the pattern-layout encoder for this appender's logcat tag
|
void |
start()
Checks that required parameters are set, and if everything is in order,
activates this appender.
|
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, stop, toString
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
public LogcatAppender()
public void start()
start
in interface LifeCycle
start
in class AppenderBase<ILoggingEvent>
public void append(ILoggingEvent event)
append
in class AppenderBase<ILoggingEvent>
event
- the event to be loggedpublic PatternLayoutEncoder getEncoder()
public void setEncoder(PatternLayoutEncoder encoder)
encoder
- the pattern-layout encoderpublic PatternLayoutEncoder getTagEncoder()
public void setTagEncoder(PatternLayoutEncoder encoder)
The expanded text of the pattern must be less than 23 characters as limited by Android. Layouts that exceed this limit are truncated, and a star is appended to the tag to indicate this.
The tagEncoder
result is limited to 22 characters plus a star to
indicate truncation (%logger{0}
has no length limit in logback,
but LogcatAppender
limits the length internally). For example,
if the tagEncoder
evaluated to foo.foo.foo.foo.foo.bar.Test
,
the tag seen in Logcat would be: foo.foo.foo.foo.foo.ba*
.
Note that %logger{23}
yields more useful results
(in this case: f.f.foo.foo.bar.Test
).
encoder
- the pattern-layout encoder; specify null
to
automatically use the logger's name as the tagpublic void setCheckLoggable(boolean enable)
android.util.Log.html#isLoggable
).
See http://developer.android.com/reference/android/util/Log.html#isLoggable(java.lang.String, int)
enable
- true
to enable; false
to disablepublic boolean getCheckLoggable()
isLoggable()
-check
that is called before logging
See http://developer.android.com/reference/android/util/Log.html#isLoggable(java.lang.String, int)
true
if enabled; false
otherwiseprotected String getTag(ILoggingEvent event)
event
- logging event to evaluateCopyright © 2005–2014 QOS.ch. All rights reserved.