blob: 3c33049cf949ce4c080b12c46cb5958776ef593c [file] [log] [blame]
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from src/site/apt/expression-rules.apt at 2022-05-30
| Rendered using Apache Maven Fluido Skin 1.8
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Apache Maven Doxia Site Renderer 1.9.2" />
<title>Apache Chainsaw &#x2013; </title>
<link rel="stylesheet" href="./css/apache-maven-fluido-1.8.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script src="./js/apache-maven-fluido-1.8.min.js"></script>
</head>
<body class="topBarDisabled">
<div class="container-fluid">
<header>
<div id="banner">
<div class="pull-left"><a href="http://logging.apache.org/" id="bannerLeft"><img src="images/ls-logo.jpg" alt="Logging Services"/></a></div>
<div class="pull-right"><a href="../log4j/2.x/" id="bannerRight"><img src="images/logo.png" alt="Apache log4j"/></a></div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2022-05-30<span class="divider">|</span>
</li>
<li id="projectVersion">Version: 2.2.0-SNAPSHOT<span class="divider">|</span></li>
<li class=""><a href="http://www.apache.org/" class="externalLink" title="Apache">Apache</a><span class="divider">/</span></li>
<li class=""><a href="http://logging.apache.org/" class="externalLink" title="Logging Services">Logging Services</a><span class="divider">/</span></li>
<li class=""><a href="http://logging.apache.org:80/chainsaw/" class="externalLink" title="Chainsaw">Chainsaw</a><span class="divider">/</span></li>
<li class="active "></li>
</ul>
</div>
</header>
<div class="row-fluid">
<header id="leftColumn" class="span2">
<nav class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Get Chainsaw</li>
<li><a href="download.html" title="Download"><span class="none"></span>Download</a></li>
<li><a href="changes-report.html" title="Changes"><span class="none"></span>Changes</a></li>
<li><a href="https://www.apache.org/licenses/LICENSE-2.0" class="externalLink" title="License"><span class="none"></span>License</a></li>
<li><a href="distributionnotes.html" title="Important Distribution Notes"><span class="none"></span>Important Distribution Notes</a></li>
<li class="nav-header">About Chainsaw</li>
<li><a href="index.html" title="Introduction"><span class="none"></span>Introduction</a></li>
<li><a href="quicktour.html" title="Quick Tour"><span class="none"></span>Quick Tour</a></li>
<li><a href="zeroconf.html" title="Zeroconf"><span class="none"></span>Zeroconf</a></li>
<li><a href="roadmap.html" title="Roadmap"><span class="none"></span>Roadmap</a></li>
<li><a href="apidocs/index.html" title="JavaDoc"><span class="none"></span>JavaDoc</a></li>
<li class="nav-header">Manual</li>
<li><a href="viewing-log-events.html" title="Viewing Log Events"><span class="none"></span>Viewing Log Events</a></li>
<li><a href="colorizing-output.html" title="Colorizing Output"><span class="none"></span>Colorizing Output</a></li>
<li class="active"><a href="#"><span class="none"></span>Expression Rules</a></li>
<li><a href="configuration-library.html" title="Configuration Library"><span class="none"></span>Configuration Library</a></li>
<li class="nav-header">Community</li>
<li><a href="mail-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a></li>
<li><a href="issue-tracking.html" title="Issue Tracking"><span class="none"></span>Issue Tracking</a></li>
<li class="nav-header">Development</li>
<li><a href="source-repository.html" title="Repository"><span class="none"></span>Repository</a></li>
<li><a href="xref/index.html" title="Cross Reference"><span class="none"></span>Cross Reference</a></li>
<li><a href="dependencies.html" title="Dependencies"><span class="none"></span>Dependencies</a></li>
<li><a href="cpd.html" title="Duplication"><span class="none"></span>Duplication</a></li>
<li><a href="pmd.html" title="PMD"><span class="none"></span>PMD</a></li>
<li class="nav-header">Apache</li>
<li><a href="http://www.apache.org" class="externalLink" title="Home"><span class="none"></span>Home</a></li>
<li><a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"><span class="none"></span>Sponsorship</a></li>
<li><a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a></li>
<li><a href="https://www.apache.org/security/" class="externalLink" title="Security"><span class="none"></span>Security</a></li>
<li><a href="http://www.apachecon.com" class="externalLink" title="Conferences"><span class="none"></span>Conferences</a></li>
</ul>
</nav>
<div class="well sidebar-nav">
<hr />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
</div>
</div>
</header>
<main id="bodyColumn" class="span10" >
<section>
<h2><a name="Expression_Rules"></a>Expression Rules</h2>
<p>In order to select specified messages, Chainsaw allows you to define an expression rule that will match zero or more messages. These expressions can be used to search for messages, or to colorize messages.</p></section><section>
<h2><a name="Basic_Operators"></a>Basic Operators</h2>
<p>The basic operators are similar to normal programming operators. They are:</p>
<table border="1" class="table table-striped">
<tr class="a">
<th align="center">Operator</th>
<th align="center">Meaning</th></tr>
<tr class="b">
<td align="center">!</td>
<td align="center">Not</td></tr>
<tr class="a">
<td align="center">!=</td>
<td align="center">Not Equal</td></tr>
<tr class="b">
<td align="center">==</td>
<td align="center">Equal</td></tr>
<tr class="a">
<td align="center">~=</td>
<td align="center">CASE-INSENSITIVE equals operator</td></tr>
<tr class="b">
<td align="center">||</td>
<td align="center">OR</td></tr>
<tr class="a">
<td align="center">&amp;&amp;</td>
<td align="center">And</td></tr>
<tr class="b">
<td align="center">like</td>
<td align="center">REGEXP operator</td></tr>
<tr class="a">
<td align="center">exists</td>
<td align="center">Not NULL</td></tr>
<tr class="b">
<td align="center">&lt;</td>
<td align="center">Less Than</td></tr>
<tr class="a">
<td align="center">&lt;=</td>
<td align="center">Less Than or equal</td></tr>
<tr class="b">
<td align="center">&gt;</td>
<td align="center">Greater Than</td></tr>
<tr class="a">
<td align="center">&gt;=</td>
<td align="center">Greater Than or equal</td></tr></table></section><section>
<h2><a name="Grouping_Expressions"></a>Grouping Expressions</h2>
<p>As with mathematical expressions, ordering/grouping can be enforced by using parentheses around the parts to group.</p></section><section>
<h2><a name="Fields_to_Match"></a>Fields to Match</h2>
<p>Expressions that are made can match on specific fields of a message. The fields that can be matched are as follows:</p>
<table border="1" class="table table-striped">
<tr class="a">
<th align="center">Field</th>
<td align="center">Meaning</td></tr>
<tr class="b">
<td align="center">LOGGER</td>
<td align="center">The logger that produced this log message</td></tr>
<tr class="a">
<td align="center">LEVEL</td>
<td align="center">The severity of the log message</td></tr>
<tr class="b">
<td align="center">CLASS</td>
<td align="center">The class that this log message is from</td></tr>
<tr class="a">
<td align="center">FILE</td>
<td align="center">The file that this log message was logged in</td></tr>
<tr class="b">
<td align="center">METHOD</td>
<td align="center">The method that produced this log message</td></tr>
<tr class="a">
<td align="center">MSG</td>
<td align="center">The log message</td></tr>
<tr class="b">
<td align="center">NDC</td>
<td align="center">The Nested Diagnostic Context of this message</td></tr>
<tr class="a">
<td align="center">EXCEPTION</td>
<td align="center">The exception in the log message</td></tr>
<tr class="b">
<td align="center">TIMESTAMP</td>
<td align="center">When the log message was created</td></tr>
<tr class="a">
<td align="center">THREAD</td>
<td align="center">The thread that produced this log message</td></tr></table></section><section>
<h2><a name="Examples"></a>Examples</h2>
<p>Capture messages at DEBUG level</p>
<div class="source"><pre class="prettyprint">LEVEL==DEBUG</pre></div>
<p>Capture message at DEBUG and TRACE levels(trace is less than DEBUG)</p>
<div class="source"><pre class="prettyprint">LEVEL&lt;=DEBUG</pre></div>
<p>Capture DEBUG and TRACE messages for the logger named 'com'</p>
<div class="source"><pre class="prettyprint">LEVEL&lt;=DEBUG &amp;&amp; LOGGER==com</pre></div>
<p>Capture messages that have the string 'specific' in the message</p>
<div class="source"><pre class="prettyprint">MSG like .*specific.*</pre></div>
<p>Capture messages that are at INFO or above, or (messages that start with 'Start' or loggers named 'test').</p>
<div class="source"><pre class="prettyprint">level &gt;= INFO || ( msg like 'Start.*' || logger == 'test' )</pre></div></section>
</main>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
<p>Copyright &#169; 2002&#x2013;2022<a href="https://www.apache.org/">The Apache Software Foundation</a>.
.</p>
</div>
</div>
</footer>
</body>
</html>