blob: 5e6926295434b35bb15706aeb98b3b08b811cbdc [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_144) on Wed Dec 11 21:05:24 MST 2019 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>AsynchronouslyFormattable (Apache Log4j API 2.13.0 API)</title>
<meta name="date" content="2019-12-11">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="AsynchronouslyFormattable (Apache Log4j API 2.13.0 API)";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/AsynchronouslyFormattable.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/logging/log4j/message/AbstractMessageFactory.html" title="class in org.apache.logging.log4j.message"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/logging/log4j/message/DefaultFlowMessageFactory.html" title="class in org.apache.logging.log4j.message"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/logging/log4j/message/AsynchronouslyFormattable.html" target="_top">Frames</a></li>
<li><a href="AsynchronouslyFormattable.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Required&nbsp;|&nbsp;</li>
<li>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Element</li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.logging.log4j.message</div>
<h2 title="Annotation Type AsynchronouslyFormattable" class="title">Annotation Type AsynchronouslyFormattable</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/Documented.html?is-external=true" title="class or interface in java.lang.annotation">@Documented</a>
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/Target.html?is-external=true" title="class or interface in java.lang.annotation">@Target</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/Target.html?is-external=true#value--" title="class or interface in java.lang.annotation">value</a>=<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/ElementType.html?is-external=true#TYPE" title="class or interface in java.lang.annotation">TYPE</a>)
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/Retention.html?is-external=true" title="class or interface in java.lang.annotation">@Retention</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/Retention.html?is-external=true#value--" title="class or interface in java.lang.annotation">value</a>=<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/RetentionPolicy.html?is-external=true#RUNTIME" title="class or interface in java.lang.annotation">RUNTIME</a>)
public @interface <a href="../../../../../src-html/org/apache/logging/log4j/message/AsynchronouslyFormattable.html#line.59">AsynchronouslyFormattable</a></pre>
<div class="block">Annotation that signals to asynchronous logging components that messages of this type can safely be passed to
a background thread without calling <a href="../../../../../org/apache/logging/log4j/message/Message.html#getFormattedMessage--"><code>Message.getFormattedMessage()</code></a> first.
<p>
Generally, logging mutable objects asynchronously always has the risk that the object is modified between the time
the logger is called and the time the log message is formatted and written to disk. Strictly speaking it is the
responsibility of the application to ensure that mutable objects are not modified after they have been logged,
but this is not always possible.
</p><p>
Log4j prevents the above race condition as follows:
</p><ol>
<li>If the Message implements <a href="../../../../../org/apache/logging/log4j/message/ReusableMessage.html" title="interface in org.apache.logging.log4j.message"><code>ReusableMessage</code></a>, asynchronous logging components in the Log4j implementation
will copy the message content (formatted message, parameters) onto the queue rather than passing the
<code>Message</code> instance itself. This ensures that the formatted message will not change
when the mutable object is modified.
</li>
<li>If the Message is annotated with <a href="../../../../../org/apache/logging/log4j/message/AsynchronouslyFormattable.html" title="annotation in org.apache.logging.log4j.message"><code>AsynchronouslyFormattable</code></a>, it can be passed to another thread as is.</li>
<li>Otherwise, asynchronous logging components in the Log4j implementation will call
<a href="../../../../../org/apache/logging/log4j/message/Message.html#getFormattedMessage--"><code>Message.getFormattedMessage()</code></a> before passing the Message object to another thread.
This gives the Message implementation class a chance to create a formatted message String with the current value
of the mutable object. The intention is that the Message implementation caches this formatted message and returns
it on subsequent calls.
(See <a href="https://issues.apache.org/jira/browse/LOG4J2-763">LOG4J2-763</a>.)
</li>
</ol></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.8</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../org/apache/logging/log4j/message/Message.html" title="interface in org.apache.logging.log4j.message"><code>Message</code></a>,
<a href="../../../../../org/apache/logging/log4j/message/ReusableMessage.html" title="interface in org.apache.logging.log4j.message"><code>ReusableMessage</code></a>,
<a href="https://issues.apache.org/jira/browse/LOG4J2-763">LOG4J2-763</a></dd>
</dl>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/AsynchronouslyFormattable.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/logging/log4j/message/AbstractMessageFactory.html" title="class in org.apache.logging.log4j.message"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/logging/log4j/message/DefaultFlowMessageFactory.html" title="class in org.apache.logging.log4j.message"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/logging/log4j/message/AsynchronouslyFormattable.html" target="_top">Frames</a></li>
<li><a href="AsynchronouslyFormattable.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Required&nbsp;|&nbsp;</li>
<li>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Element</li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small><p align="center">Copyright &#169; 1999-2019 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.<br /> Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.</p></small></p>
</body>
</html>