java


LogBack Message ILoggingEvent


I have a class that extends LayoutBase. In the doLayout method, I add a key to my logging called MSG and the value is set to ILoggingEvent event.getMessage().
I'm seeing values added to my logging but they're not consistent; some logging messages and some exception stack traces.
Can anyone tell me where ILoggingEvent event.getMessage() gets its value from?
Please refer to Logback architecture
It mentions that each log will go through series of step
Get Filter Chain Decision
If it exists, the TurboFilter chain is invoked. Turbo filters can set a context-wide threshold, or filter out certain events based on information such as Marker, Level, Logger, message, or the Throwable that are associated with each logging request.
Apply the selection rule
At this step, logback compares the effective level of the logger with the level of the request. If the logging request is disabled according to this test, then logback will drop the request without further processing.
Create a LoggingEvent object
If the request survived the previous filters, logback will create a LoggingEvent object containing all the relevant parameters of the request
Invoking appenders
After the creation of a LoggingEvent object, logback will invoke the doAppend() methods of all the applicable appenders, that is, the appenders inherited from the logger context.
Formatting the output
It is the responsibility of the invoked appender to format the logging event. However, some (but not all) appenders delegate the task of formatting the logging event to a layout.
Sending out the LoggingEvent
After the logging event is fully formatted it is sent to its destination by each appender.
I'm seeing values added to my logging but they're not consistent; some logging messages and some exception stack traces.
Now, coming to your query, it seems that you are receiving events which have exception information (Throwable) during the formatting step.
You can create a CustomFilter to filter out such events. All you have to do is extends Filter<ILoggingEvent>
public class DenyExceptionFilter extends Filter<ILoggingEvent> {
#Override
public FilterReply decide(ILoggingEvent iLoggingEvent) {
final IThrowableProxy throwableProxy = iLoggingEvent.getThrowableProxy();
if (throwableProxy != null && throwableProxy instanceof ThrowableProxy)
return FilterReply.DENY;
return FilterReply.ACCEPT;
}
}
This can be much more powerful, can filter specific types of exception. You can take this as your homework :P
Then you can add this Custom Filter to your appender as
<appender name="APPENDER_NAME" class="ch.qos.logback.classic.AsyncAppender">
<filter class="com.stackoverflow.DenyExceptionFilter" />
</appender>
Of course, add your layout as well after the filter.

Related Links

ODBC Error: Invalid String or Buffer Length--Microsoft Server 2008 32bit vs 2008 R2 64bit
Is there any Java Look and Feel implementation using only console?
Implement probability distribution function in Java problem
Java JTextArea handling undisplayable ASCII sequences
Java - Using Hashtable with Interface as value
Java installer with support for windows service
Why should i give a name to an If Statement?
BaseAdapter in ListActivity isn't displaying the correct items
Java dump an object
Why use a bitwise AND here?
Java HTML files and JEditor Pane
Checking JAR Usage at the Package Level
I'm really having trouble figuring out how to make my GUI window display the values in the array
Create a file object from a resource path to an image in a jar file
Java Object[] cast to long[][] performance issuse?
Does “/* (non-javadoc)” have a well-understood meaning?

Categories

HOME
xamarin
angular-material
react-router
packages
flyway4
ios-charts
android-youtube-api
cross-validation
esper
python-unittest
vault
user-input
quicklook
windows-phone-7
dynamics-crm-online
try-catch
jsprit
facebook-page
code-review
nodatime
jtextfield
google-search-api
pass-by-reference
telerik-reporting
hammerspoon
icloud-api
emgucv
vlsi
qhull
su
wpfdatagrid
pingfederate
traffic
greendao
fluentvalidation
quote
procdump
newline
flink-streaming
stormpath
data-manipulation
accelerate-framework
gammu
dosbox
serverside-rendering
theano.scan
ncalc
firebase-admin
nomethoderror
vao
qcombobox
apple-news
scrollable
gabor-filter
yii2-extension
colorama
np-complete
sybase-asa
knpmenubundle
hittest
bind9
or-tools
mediaelement
objective-c-swift-bridge
root-framework
deadbolt-2
slicknav
phishing
impresspages
firebaseui
php-internals
itextpdf
associative-array
system.management
energy
srand
android-listview
0xdbe
twirl
event-bubbling
composite
sonarqube5.1.2
python-green
sorl-thumbnail
tween
fpml
fluentautomation
seaside
didselectrowatindexpath
typo3-neos
cdc
buster.js
lcs
wsdl-2.0
viewswitcher
pydot
ecl
coda-slider
sortable-tables
.nettiers
icanhaz.js
boost-smart-ptr
phonon
rtml
lzh

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile