1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
|
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Logback Error Codes</title>
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/screen.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/_print.css" media="print" />
<link rel="stylesheet" type="text/css" href="css/prettify.css" />
<style type="text/css">
h3.doAnchor {
border-top: 2px solid #888888;
/*color: #333;*/
padding-bottom: 1ex;
padding-top: 1ex;
}
</style>
</head>
<body onload="prettyPrint(); decorate();">
<script type="text/javascript" src="js/prettify.js"></script>
<script type="text/javascript">prefix='';</script>
<script type="text/javascript" src="templates/header.js"></script>
<script type="text/javascript" src="js/jquery-min.js"></script>
<script type="text/javascript" src="js/decorator.js"></script>
<div id="left">
<script src="templates/left.js" type="text/javascript"></script>
</div>
<div id="content">
<h2><a name="top">Logback error messages and their meanings</a></h2>
<h3 class="doAnchor" name="null_CS">The contextSelector cannot be
null in <code>StaticLoggerBinder</code>.
</h3>
<p>An <code>IllegalStateException</code> is thrown when no
ContextSelector could be set for logback's
<code>StaticLoggerBinder</code>. In principle, this error can only
occur when the context selector is expressly specified by the user,
and when that context selector cannot not be instantiated correctly.
</p>
<p>It should not happen when you are using the default or JNDI
context selectors.
</p>
<!-- =========================================================== -->
<h3 class="doAnchor" name="layoutInsteadOfEncoder">This appender no
longer admits a layout as a sub-component, set an encoder instead.
</h3>
<p>As of logback version 0.9.19, the <code>WriterAppender</code>
class has been renamed as <code>OutputStreamAppender</code>, with
<code>FileAppender</code> now sub-classing the
latter. <code>OutputStreamAppender</code> and sub-classes now take
an <code>Encoder</code> as a sub-component instead of a
<code>Layout</code>.
</p>
<p>In practical terms, this means that configuration files need to
be changed</p>
<p class="red bold">from (DEPRECATED)</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%msg%n</pattern>
</layout>
</appender> </pre>
<p class="red bold">or the shorter equivalent (DEPRECATED)</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<!-- layout are assigned the type ch.qos.logback.classic.PatternLayout by default -->
<layout>
<pattern>%msg%n</pattern>
</layout>
</appender> </pre>
<p class="green bold">to (GOOD)</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%msg%n</pattern>
</encoder>
</appender> </pre>
<p class="green bold">or the shorter equivalent (GOOD)</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender> </pre>
<p>For layout type other than <code>PatternLayout</code>, for
example <code>HTMLLayout</code>, your configuration files need to be
changed
</p>
<p class="red bold">from (DEPRECATED)</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%msg%n</pattern>
</layout>
</appender> </pre>
<p class="green bold">to (GOOD)</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%msg%n</pattern>
</layout>
</encoder>
</appender> </pre>
<p>We hope to make up for this inconvenience with cool new features
which are only possible using encoders. <b>During a transition
period, layouts passed as parameter will be automatically wrapped by
an encoder so that configuration files in the old format (using a
layout instead of encoder) will continue to work unmodified.</b>
</p>
<!-- =========================================================== -->
<h3 class="doAnchor" name="socket_no_host">No remote host or address
is set for <code>SocketAppender</code>
</h3>
<p>A remote host or address is mandatory for SocketAppender. </p>
<p>You can specify the remote host in the configuration file
as follows.
</p>
<pre class="prettyprint source"><appender name="SOCKET"
class="ch.qos.logback.classic.net.SocketAppender">
...
<remoteHost>127.0.0.1</remoteHost>
...
</appender></pre>
<!-- ============================================================= -->
<h3 class="doAnchor" name="socket_no_port">No remote port is set for
<code>SocketAppender</code>
</h3>
<p>A remote port is mandatory for SocketAppender.</p>
<p>You can specify the remote port in the configuration file
like this:
</p>
<pre class="prettyprint source"><appender name="SOCKET" class="ch.qos.logback.classic.net.SocketAppender">
...
<port>4560</port>
...
</appender></pre>
<!-- ============================================================= -->
<h3 class="doAnchor" name="smtp_no_layout">No <code>Layout</code> is
set for SMTPAppender
</h3>
<p>A <code>Layout</code> is mandatory for
<code>SMTPAppender</code>. It allows SMTPAppender to format logging
events before sending an email.
</p>
<p>You can specify the <code>Layout</code> in a configuration file
as follows:
</p>
<pre class="prettyprint source"><appender name="SMTP" class="ch.qos.logback.classic.net.SMTPAppender">
...
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date [%thread] %-5level %logger - %msg%n"></pattern>
</layout>
...
</appender></pre>
<p>SMTPAppender is known to work well with <a
href="manual/layouts.html#ClassicPatternLayout">PatternLayout</a>
and <a
href="manual/layouts.html#ClassicHTMLLayout">HTMLLayout</a>.
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="sbtp_size_format">Specified number is not
in proper int form, or not expected format.
</h3>
<p>When you specify the MaxFileSize to be used by the
SizeBasedRollingPolicy, logback expects a rather precise
format:
</p>
<ul>
<li>The number has to be an integer</li>
<li>You can add 'KB', 'MB' or 'GB' after the number.
</li>
</ul>
<p>Here are some correct values: 500KB, 15MB, 2GB.</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="rfa_no_tp">No
<code>TriggeringPolicy</code> was set for the
<code>RollingFileAppender</code>.
</h3>
<p>The <code>RollingFileAppender</code> must be set up with a
<code>TriggeringPolicy</code>. It permits the Appender to know when
the rollover must be activated.
</p>
<p>To find more information about <code>TriggeringPolicy</code>
objects, please read the following javadocs:
</p>
<ul>
<li>
<a
href="manual/appenders.html#SizeBasedTriggeringPolicy"><code>SizeBasedTriggeringPolicy</code>
</a>
</li>
<li>
<a
href="manual/appenders.html#TimeBasedRollingPolicy"><code>TimeBasedRollingPolicy</code>
</a>
</li>
</ul>
<p>Please note that the <code>TimeBasedRollingPolicy</code>
is a TriggeringPolicy <em>and</em> and
<code>RollingPolicy</code> at the same time.
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="rfa_no_rp">No <code>RollingPolicy</code>
was set for the <code>RollingFileAppender</code>.
</h3>
<p>The <code>RollingFileAppender</code> must be set up with
a <code>RollingPolicy</code>. It permits the Appender to
know what to do when a rollover is requested.
</p>
<p>To find more information about <code>RollingPolicy</code>
objects, please read the following javadocs:
</p>
<ul>
<li>
<a href="apidocs/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.html">
<code>FixedWindowRollingPolicy</code>
</a>
</li>
<li>
<a href="apidocs/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.html">
<code>TimeBasedRollingPolicy</code>
</a>
</li>
</ul>
<p>Please note that the <code>TimeBasedRollingPolicy</code> is a
<code>TriggeringPolicy</code> <em>and</em> and RollingPolicy at
the same time.
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="tbr_fnp_not_set">The <span
class="option">FileNamePattern</span> property is mandatory for both
<code>TimeBasedRollingPolicy</code> and
<code>FixedWindowRollingPolicy</code>.
</h3>
<p>The <span class="option">FileNamePattern</span> property for both
<code>TimeBasedRollingPolicy</code> and
<code>FixedWindowRollingPolicy</code> is mandatory.
</p>
<p>Please refer to the documentation of <a
href="manual/appenders.html#TimeBasedRollingPolicy">TimeBasedRollingPolicy</a>
and <a
href="manual/appenders.html#FixedWindowRollingPolicy">FixedWindowRollingPolicy</a> for
examples.
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="rfa_file_after">The <span
class="option">File</span> property must be set before any rolling
policy or triggering policy.
</h3>
<p>The <span class="option">File</span> property, if present, must
be placed before any rolling policy or triggering policy. Thus, in a
configuration file, the <span class="option">File</span> property,
if present, must be declared declared before any rolling policy or
triggering policy declarations.
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="rfa_collision"><span
class="option">File</span> property collides with <span
class="option">fileNamePattern</span>. Aborting.
</h3>
<p>When the <span class="option">file</span> property matches the
regular expression defined by <span
class="option">fileNamePattern</span>, there is a risk of
collision. A collision occurs when the active log file as defined by
the <span class="option">file</span> property has the same path as
an existing log archive. Such a collision will result in the log
archive being overwritten.
</p>
<p>As such, in case <span class="option">file</span> property
matches the regular expression defined by <span
class="option">fileNamePattern</span>, in order to avoid data loss,
<code>RollingFileAppender</code> will emit an error message and
refuse to start.</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="renamingError">Failed to rename file [x]
as [y].</h3>
<b>On Windows</b>
<p>On the Windows platform a log file cannot be renamed if there are
handles referencing it. For example, when the file is read by
another process such as <code>less</code>, <code>tail</code>,
etc. During application hot-redeployment, the old instance of the
application will have open references to log files until the old
instance is completely shutdown or until the <code>stop()</code>
method on its <a
href="apidocs/ch/qos/logback/classic/LoggerContext.html"><code>LoggerContext</code></a>
is invoked.
</p>
<p><a
href="http://technet.microsoft.com/en-us/sysinternals/bb896653">Process
Explorer</a> can help you locate the processes which reference a
given file (Find -> Find Handle or DLL). On Linux, you can use
the <code><a href="http://www.manpagez.com/man/8/lsof/">lsof </a>
<em>pathToFile</em></code> command to find which process has the
file given by <em>pathToFile</em> open. </p>
<p>Rolling might also fail due to incorrect file permission
settings. On windows, renaming a file requires the "modify"
permission which is different than the permission to "write" to the
file.</p>
<p>In practice, it can be hard to set the right permissions or to
ensure that there are no file handle references to log files. Under
such circumstances, it can be easier to avoid file renaming
altogether. File renaming can be avoided by omitting the <span
class="option">file</span> property in
<code>TimeBasedRollingPolicy</code>, as shown in the next
configuration snippet.
</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <span class="option">file</span> property left unset/blank -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>mylog.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%relative [%thread] %level %logger - %msg%n</pattern>
</encoder>
</appender></pre>
<p>Note that for <code>FixedWindowRollingPolicy</code>, the <span
class="option">file</span> property is mandatory.
</p>
<h4 class="doAnchor" name="renamingErrorOnUnix">On Unix-*</h4>
<p>On the Unix platform, the basic/quick rename method supplied by
the JDK does not work if the source and target files are located on
different file systems. In order to deal with this contingency,
logback will resort to renaming by copying if all following three
conditions are met:</p>
<ol>
<li>quick renaming fails, </li>
<li>source and destination files for the rename are on different
file systems,
</li>
<li>the host JVM platform runs Java 7 or later.</li>
</ol>
<p>The code for determining the file system of a file requires Java
7. No rename by copying will be performed on Java 6 or earlier.</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="fwrp_parentFileName_not_set">The <span
class="option">File</span> property must be set before
<code>FixedWindowRollingPolicy</code>
</h3>
<p>The <span class="option">File</span> property is mandatory with
<code>FixedWindowRollingPolicy</code>. Moreover, the <span
class="option">File</span> option must be set before the
<code>FixedWindowRollingPolicy</code> element.
</p>
<p>Refer to the logback manual on
<a href="manual/appenders.html#FixedWindowRollingPolicy">
FixedWindowRollingPolicy </a> for more information.
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="tbr_fnp_prudent_unsupported">Prudent mode
is not supported with <code>FixedWindowRollingPolicy</code>.
</h3>
<p>Given that <code>FixedWindowRollingPolicy</code> performs
multiple file rename operations during roll over, and that these
operations cannot be guaranteed to be safe in a multi-JVM context,
prudent mode is not allowed in conjunction with a
<code>FixedWindowRollingPolicy</code>.
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="syslog_layout">SyslogAppender does not
admit a layout.
</h3>
<p>Given that the format of a syslog request follows strict rules,
you cannot freely specify the layout to be used with
SyslogAppender. However, you can use <span
class="option">SuffixPattern</span> option instead to influence the
contents of the message sent to the syslog daemon.
</p>
<p>For more information on SyslogAppender please refer to the <a
href="manual/appenders.html#SyslogAppender">its documentation.</a>
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="1andOnly1">Only and only one appender can
be nested the <sift> element in
<code>SiftingAppender</code>.</h3>
<p>SiftingAppender admits one and only one nested appender.
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="ifJanino">Could not find Janino library
on the class path. Skipping conditional processing.
</h3>
<p><a href="manual/configuration.html#conditional">Conditional
processing</a> in configuration files requires the <a
href="http://docs.codehaus.org/display/JANINO/Home">Janino
library</a>. See the <a href="setup.html#janino">setup
instructions</a> for adding Janino to your class path.
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="block">As of logback version 0.9.28,
JaninoEventEvaluator expects Java blocks.
</h3>
<p>As of logback version 0.9.28, JaninoEvaluator expects Java
"block", i.e. the body of a method. In previous versions only
boolean expressions were allowed. For backward compatibility
reasons, whenever logback sees a boolean expression it will attempt
to convert it to a block by prefixing the expression with "return"
and suffixing it with a semicolon.
</p>
<p>Boolean expressions can quickly become hairy. For example, the
following boolean expression is rather difficult to grok.
</p>
<pre class="prettyprint source"> !logger.startsWith("org.apache.http")
||
( logger.equals("org.apache.http.wire") &&
(mdc != null && mdc.get("entity") != null
&&
((String) mdc.get("entity")).contains("someSpecialValue"))
&&
!message.contains("someSecret")
)</pre>
<p>whereas as its Java block equivalent is considerably easier to
follow.</p>
<pre class="prettyprint source">if(logger.startsWith("org.apache.http"))
return true;
if(mdc == null || mdc.get("entity") == null)
return false;
String payee = (String) mdc.get("entity");
if(logger.equals("org.apache.http.wire") &&
payee.contains("someSpecialValue") &&
!message.contains("someSecret")) {
return true;
}
return false;</pre>
<p>
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="missingRightParenthesis">In a conversion
pattern, opened parenthesis must be closed.
</h3>
<p>In conversion patterns, <a
href="manual/layouts.html#Parentheses">parentheses are special</a>
because they are treated as grouping tokens. If a parenthesis
character needs to be viewed as a literal, it needs to be escaped
by preceding each parenthesis with a backslash. As in,
<b>\(</b>%d{HH:mm:ss.SSS} [%thread]<b>\) </b>.
</p>
<!-- ============================================================= -->
<h3 class="doAnchor" name="appender_order">Appenders must be
definied before they are referenced.
</h3>
<p>In a configuration file, at the point where an appender is
referenced by name, it must be defined earlier in the configuration
file. Referencing an appender defined later in the file is not
allowed. Below are examples of correct and incorrect order of
definition and referece.
</p>
<p>Below is an example of a correct ordering, where appender
definition precedes references made to it.
</p>
<p class="green bold">CORRECT ORDER</p>
<pre class="prettyprint source"><configuration>
<b><!-- definition of appender STDOUT --></b>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<!-- appender referenced after it is defined -->
<b class="big"><appender-ref ref="STDOUT"/></b>
</root>
</configuration></pre>
<p>Below is an example of an incorrect ordering, where appender
definition follows references made to it.
</p>
<p class="red bold">INCORRECT ORDER</p>
<pre class="prettyprint source"><configuration>
<root level="DEBUG">
<!-- appender INCORRECTLY referenced before it is defined -->
<b class="big"><appender-ref ref="STDOUT"/></b>
</root>
<b><!-- definition of appender STDOUT --></b>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
</encoder>
</appender>
</configuration>
</pre>
<!-- =========================================================== -->
<h3 class="doAnchor" name="remote_no_host">No remote host or address
is set for <code>SocketRemote</code>
</h3>
<p>A remote host or address is mandatory for SocketRemote. </p>
<p>You can specify the remote host in the configuration file
as follows.
</p>
<pre class="prettyprint source"><remote class="ch.qos.logback.classic.net.SocketRemote">
...
<host>127.0.0.1</host>
...
</remote></pre>
<!-- ============================================================= -->
<h3 class="doAnchor" name="socket_no_port">No remote port is set for
<code>SocketRemote</code>
</h3>
<p>A remote port is mandatory for SocketRemote.</p>
<p>You can specify the remote port in the configuration file
like this:
</p>
<pre class="prettyprint source"><remote class="ch.qos.logback.classic.net.SocketRemote">
...
<port>4560</port>
...
</remote></pre>
<script src="templates/footer.js" type="text/javascript"></script>
</div>
</body>
</html>
|