001/** 002 * Copyright (c) 2004-2022 QOS.ch 003 * All rights reserved. 004 * 005 * Permission is hereby granted, free of charge, to any person obtaining 006 * a copy of this software and associated documentation files (the 007 * "Software"), to deal in the Software without restriction, including 008 * without limitation the rights to use, copy, modify, merge, publish, 009 * distribute, sublicense, and/or sell copies of the Software, and to 010 * permit persons to whom the Software is furnished to do so, subject to 011 * the following conditions: 012 * 013 * The above copyright notice and this permission notice shall be 014 * included in all copies or substantial portions of the Software. 015 * 016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 017 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 019 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 020 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 021 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 022 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 023 * 024 */ 025 026package org.slf4j; 027 028import static org.slf4j.event.EventConstants.DEBUG_INT; 029import static org.slf4j.event.EventConstants.ERROR_INT; 030import static org.slf4j.event.EventConstants.INFO_INT; 031import static org.slf4j.event.EventConstants.TRACE_INT; 032import static org.slf4j.event.EventConstants.WARN_INT; 033import static org.slf4j.event.Level.DEBUG; 034import static org.slf4j.event.Level.ERROR; 035import static org.slf4j.event.Level.INFO; 036import static org.slf4j.event.Level.TRACE; 037import static org.slf4j.event.Level.WARN; 038 039import org.slf4j.event.Level; 040import org.slf4j.helpers.CheckReturnValue; 041import org.slf4j.spi.DefaultLoggingEventBuilder; 042import org.slf4j.spi.LoggingEventBuilder; 043import org.slf4j.spi.NOPLoggingEventBuilder; 044 045/** 046 * The org.slf4j.Logger interface is the main user entry point of SLF4J API. 047 * It is expected that logging takes place through concrete implementations 048 * of this interface. 049 * 050 * <H3>Typical usage pattern:</H3> 051 * <pre> 052 * import org.slf4j.Logger; 053 * import org.slf4j.LoggerFactory; 054 * 055 * public class Wombat { 056 * 057 * <span style="color:green">final static Logger logger = LoggerFactory.getLogger(Wombat.class);</span> 058 * Integer t; 059 * Integer oldT; 060 * 061 * public void setTemperature(Integer temperature) { 062 * oldT = t; 063 * t = temperature; 064 * <span style="color:green">logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);</span> 065 * if (temperature.intValue() > 50) { 066 * <span style="color:green">logger.info("Temperature has risen above 50 degrees.");</span> 067 * } 068 * } 069 * } 070 * </pre> 071 * 072 * <p>Note that version 2.0 of the SLF4J API introduces a <a href="../../../manual.html#fluent">fluent api</a>, 073 * the most significant API change to occur in the last 20 years. 074 * 075 * <p>Be sure to read the FAQ entry relating to <a href="../../../faq.html#logging_performance">parameterized 076 * logging</a>. Note that logging statements can be parameterized in 077 * <a href="../../../faq.html#paramException">presence of an exception/throwable</a>. 078 * 079 * <p>Once you are comfortable using loggers, i.e. instances of this interface, consider using 080 * <a href="MDC.html">MDC</a> as well as <a href="Marker.html">Markers</a>. 081 * 082 * @author Ceki Gülcü 083 */ 084public interface Logger { 085 086 /** 087 * Case-insensitive String constant used to retrieve the name of the root logger. 088 * 089 * @since 1.3 090 */ 091 final public String ROOT_LOGGER_NAME = "ROOT"; 092 093 /** 094 * Return the name of this <code>Logger</code> instance. 095 * @return name of this logger instance 096 */ 097 public String getName(); 098 099 /** 100 * <p>Make a new {@link LoggingEventBuilder} instance as appropriate for this logger implementation. 101 * This default implementation always returns a new instance of {@link DefaultLoggingEventBuilder}.</p> 102 * <p></p> 103 * <p>This method is intended to be used by logging systems implementing the SLF4J API and <b>not</b> 104 * by end users.</p> 105 * <p></p> 106 * <p>Also note that a {@link LoggingEventBuilder} instance should be built for all levels, 107 * independently of the level argument. In other words, this method is an <b>unconditional</b> 108 * constructor for the {@link LoggingEventBuilder} appropriate for this logger implementation.</p> 109 * <p></p> 110 * @param level desired level for the event builder 111 * @return a new {@link LoggingEventBuilder} instance as appropriate for <b>this</b> logger 112 * @since 2.0 113 */ 114 default public LoggingEventBuilder makeLoggingEventBuilder(Level level) { 115 return new DefaultLoggingEventBuilder(this, level); 116 } 117 118 /** 119 * <p>Make a new {@link LoggingEventBuilder} instance as appropriate for this logger and the 120 * desired {@link Level} passed as parameter. If this Logger is disabled for the given Level, then 121 * a {@link NOPLoggingEventBuilder} is returned. This is the main optimization in the fluent API.</p> 122 * 123 * 124 * @param level desired level for the event builder 125 * @return a new {@link LoggingEventBuilder} instance as appropriate for this logger 126 * @since 2.0 127 */ 128 @CheckReturnValue 129 default public LoggingEventBuilder atLevel(Level level) { 130 if (isEnabledForLevel(level)) { 131 return makeLoggingEventBuilder(level); 132 } else { 133 return NOPLoggingEventBuilder.singleton(); 134 } 135 } 136 137 138 139 /** 140 * Returns whether this Logger is enabled for a given {@link Level}. 141 * 142 * @param level 143 * @return true if enabled, false otherwise. 144 */ 145 default public boolean isEnabledForLevel(Level level) { 146 int levelInt = level.toInt(); 147 switch (levelInt) { 148 case (TRACE_INT): 149 return isTraceEnabled(); 150 case (DEBUG_INT): 151 return isDebugEnabled(); 152 case (INFO_INT): 153 return isInfoEnabled(); 154 case (WARN_INT): 155 return isWarnEnabled(); 156 case (ERROR_INT): 157 return isErrorEnabled(); 158 default: 159 throw new IllegalArgumentException("Level [" + level + "] not recognized."); 160 } 161 } 162 163 /** 164 * Is the logger instance enabled for the TRACE level? 165 * 166 * @return True if this Logger is enabled for the TRACE level, 167 * false otherwise. 168 * @since 1.4 169 */ 170 public boolean isTraceEnabled(); 171 172 /** 173 * Log a message at the TRACE level. 174 * 175 * @param msg the message string to be logged 176 * @since 1.4 177 */ 178 public void trace(String msg); 179 180 /** 181 * Log a message at the TRACE level according to the specified format 182 * and argument. 183 * 184 * <p>This form avoids superfluous object creation when the logger 185 * is disabled for the TRACE level. 186 * 187 * @param format the format string 188 * @param arg the argument 189 * @since 1.4 190 */ 191 public void trace(String format, Object arg); 192 193 /** 194 * Log a message at the TRACE level according to the specified format 195 * and arguments. 196 * 197 * <p>This form avoids superfluous object creation when the logger 198 * is disabled for the TRACE level. 199 * 200 * @param format the format string 201 * @param arg1 the first argument 202 * @param arg2 the second argument 203 * @since 1.4 204 */ 205 public void trace(String format, Object arg1, Object arg2); 206 207 /** 208 * Log a message at the TRACE level according to the specified format 209 * and arguments. 210 * 211 * <p>This form avoids superfluous string concatenation when the logger 212 * is disabled for the TRACE level. However, this variant incurs the hidden 213 * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, 214 * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and 215 * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost. 216 * 217 * @param format the format string 218 * @param arguments a list of 3 or more arguments 219 * @since 1.4 220 */ 221 public void trace(String format, Object... arguments); 222 223 /** 224 * Log an exception (throwable) at the TRACE level with an 225 * accompanying message. 226 * 227 * @param msg the message accompanying the exception 228 * @param t the exception (throwable) to log 229 * @since 1.4 230 */ 231 public void trace(String msg, Throwable t); 232 233 /** 234 * Similar to {@link #isTraceEnabled()} method except that the 235 * marker data is also taken into account. 236 * 237 * @param marker The marker data to take into consideration 238 * @return True if this Logger is enabled for the TRACE level, 239 * false otherwise. 240 * 241 * @since 1.4 242 */ 243 public boolean isTraceEnabled(Marker marker); 244 245 /** 246 * Entry point for fluent-logging for {@link org.slf4j.event.Level#TRACE} level. 247 * 248 * <p>If this logger is disabled for the TRACE level, then a {@link NOPLoggingEventBuilder} instance is returned. 249 * As the name indicates, this builder does not perform any operations. This is the main optimization in the fluent API.</p> 250 * 251 * @return LoggingEventBuilder instance as appropriate for level TRACE 252 * @since 2.0 253 */ 254 @CheckReturnValue 255 default public LoggingEventBuilder atTrace() { 256 if (isTraceEnabled()) { 257 return makeLoggingEventBuilder(TRACE); 258 } else { 259 return NOPLoggingEventBuilder.singleton(); 260 } 261 } 262 263 /** 264 * Log a message with the specific Marker at the TRACE level. 265 * 266 * @param marker the marker data specific to this log statement 267 * @param msg the message string to be logged 268 * @since 1.4 269 */ 270 public void trace(Marker marker, String msg); 271 272 /** 273 * This method is similar to {@link #trace(String, Object)} method except that the 274 * marker data is also taken into consideration. 275 * 276 * @param marker the marker data specific to this log statement 277 * @param format the format string 278 * @param arg the argument 279 * @since 1.4 280 */ 281 public void trace(Marker marker, String format, Object arg); 282 283 /** 284 * This method is similar to {@link #trace(String, Object, Object)} 285 * method except that the marker data is also taken into 286 * consideration. 287 * 288 * @param marker the marker data specific to this log statement 289 * @param format the format string 290 * @param arg1 the first argument 291 * @param arg2 the second argument 292 * @since 1.4 293 */ 294 public void trace(Marker marker, String format, Object arg1, Object arg2); 295 296 /** 297 * This method is similar to {@link #trace(String, Object...)} 298 * method except that the marker data is also taken into 299 * consideration. 300 * 301 * @param marker the marker data specific to this log statement 302 * @param format the format string 303 * @param argArray an array of arguments 304 * @since 1.4 305 */ 306 public void trace(Marker marker, String format, Object... argArray); 307 308 /** 309 * This method is similar to {@link #trace(String, Throwable)} method except that the 310 * marker data is also taken into consideration. 311 * 312 * @param marker the marker data specific to this log statement 313 * @param msg the message accompanying the exception 314 * @param t the exception (throwable) to log 315 * @since 1.4 316 */ 317 public void trace(Marker marker, String msg, Throwable t); 318 319 /** 320 * Is the logger instance enabled for the DEBUG level? 321 * 322 * @return True if this Logger is enabled for the DEBUG level, 323 * false otherwise. 324 */ 325 public boolean isDebugEnabled(); 326 327 /** 328 * Log a message at the DEBUG level. 329 * 330 * @param msg the message string to be logged 331 */ 332 public void debug(String msg); 333 334 /** 335 * Log a message at the DEBUG level according to the specified format 336 * and argument. 337 * 338 * <p>This form avoids superfluous object creation when the logger 339 * is disabled for the DEBUG level. 340 * 341 * @param format the format string 342 * @param arg the argument 343 */ 344 public void debug(String format, Object arg); 345 346 /** 347 * Log a message at the DEBUG level according to the specified format 348 * and arguments. 349 * 350 * <p>This form avoids superfluous object creation when the logger 351 * is disabled for the DEBUG level. 352 * 353 * @param format the format string 354 * @param arg1 the first argument 355 * @param arg2 the second argument 356 */ 357 public void debug(String format, Object arg1, Object arg2); 358 359 /** 360 * Log a message at the DEBUG level according to the specified format 361 * and arguments. 362 * 363 * <p>This form avoids superfluous string concatenation when the logger 364 * is disabled for the DEBUG level. However, this variant incurs the hidden 365 * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, 366 * even if this logger is disabled for DEBUG. The variants taking 367 * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two} 368 * arguments exist solely in order to avoid this hidden cost. 369 * 370 * @param format the format string 371 * @param arguments a list of 3 or more arguments 372 */ 373 public void debug(String format, Object... arguments); 374 375 /** 376 * Log an exception (throwable) at the DEBUG level with an 377 * accompanying message. 378 * 379 * @param msg the message accompanying the exception 380 * @param t the exception (throwable) to log 381 */ 382 public void debug(String msg, Throwable t); 383 384 /** 385 * Similar to {@link #isDebugEnabled()} method except that the 386 * marker data is also taken into account. 387 * 388 * @param marker The marker data to take into consideration 389 * @return True if this Logger is enabled for the DEBUG level, 390 * false otherwise. 391 */ 392 public boolean isDebugEnabled(Marker marker); 393 394 /** 395 * Log a message with the specific Marker at the DEBUG level. 396 * 397 * @param marker the marker data specific to this log statement 398 * @param msg the message string to be logged 399 */ 400 public void debug(Marker marker, String msg); 401 402 /** 403 * This method is similar to {@link #debug(String, Object)} method except that the 404 * marker data is also taken into consideration. 405 * 406 * @param marker the marker data specific to this log statement 407 * @param format the format string 408 * @param arg the argument 409 */ 410 public void debug(Marker marker, String format, Object arg); 411 412 /** 413 * This method is similar to {@link #debug(String, Object, Object)} 414 * method except that the marker data is also taken into 415 * consideration. 416 * 417 * @param marker the marker data specific to this log statement 418 * @param format the format string 419 * @param arg1 the first argument 420 * @param arg2 the second argument 421 */ 422 public void debug(Marker marker, String format, Object arg1, Object arg2); 423 424 /** 425 * This method is similar to {@link #debug(String, Object...)} 426 * method except that the marker data is also taken into 427 * consideration. 428 * 429 * @param marker the marker data specific to this log statement 430 * @param format the format string 431 * @param arguments a list of 3 or more arguments 432 */ 433 public void debug(Marker marker, String format, Object... arguments); 434 435 /** 436 * This method is similar to {@link #debug(String, Throwable)} method except that the 437 * marker data is also taken into consideration. 438 * 439 * @param marker the marker data specific to this log statement 440 * @param msg the message accompanying the exception 441 * @param t the exception (throwable) to log 442 */ 443 public void debug(Marker marker, String msg, Throwable t); 444 445 /** 446 * Entry point for fluent-logging for {@link org.slf4j.event.Level#DEBUG} level. 447 * 448 * <p>If this logger is disabled for the DEBUG level, then a {@link NOPLoggingEventBuilder} instance is returned. 449 * As the name indicates, this builder does not perform any operations. This is the main optimization in the fluent API.</p> 450 * 451 * @return LoggingEventBuilder instance as appropriate for level DEBUG 452 * @since 2.0 453 */ 454 @CheckReturnValue 455 default public LoggingEventBuilder atDebug() { 456 if (isDebugEnabled()) { 457 return makeLoggingEventBuilder(DEBUG); 458 } else { 459 return NOPLoggingEventBuilder.singleton(); 460 } 461 } 462 463 /** 464 * Is the logger instance enabled for the INFO level? 465 * 466 * @return True if this Logger is enabled for the INFO level, 467 * false otherwise. 468 */ 469 public boolean isInfoEnabled(); 470 471 /** 472 * Log a message at the INFO level. 473 * 474 * @param msg the message string to be logged 475 */ 476 public void info(String msg); 477 478 /** 479 * Log a message at the INFO level according to the specified format 480 * and argument. 481 * 482 * <p>This form avoids superfluous object creation when the logger 483 * is disabled for the INFO level. 484 * 485 * @param format the format string 486 * @param arg the argument 487 */ 488 public void info(String format, Object arg); 489 490 /** 491 * Log a message at the INFO level according to the specified format 492 * and arguments. 493 * 494 * <p>This form avoids superfluous object creation when the logger 495 * is disabled for the INFO level. 496 * 497 * @param format the format string 498 * @param arg1 the first argument 499 * @param arg2 the second argument 500 */ 501 public void info(String format, Object arg1, Object arg2); 502 503 /** 504 * Log a message at the INFO level according to the specified format 505 * and arguments. 506 * 507 * <p>This form avoids superfluous string concatenation when the logger 508 * is disabled for the INFO level. However, this variant incurs the hidden 509 * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, 510 * even if this logger is disabled for INFO. The variants taking 511 * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two} 512 * arguments exist solely in order to avoid this hidden cost. 513 * 514 * @param format the format string 515 * @param arguments a list of 3 or more arguments 516 */ 517 public void info(String format, Object... arguments); 518 519 /** 520 * Log an exception (throwable) at the INFO level with an 521 * accompanying message. 522 * 523 * @param msg the message accompanying the exception 524 * @param t the exception (throwable) to log 525 */ 526 public void info(String msg, Throwable t); 527 528 /** 529 * Similar to {@link #isInfoEnabled()} method except that the marker 530 * data is also taken into consideration. 531 * 532 * @param marker The marker data to take into consideration 533 * @return true if this Logger is enabled for the INFO level, 534 * false otherwise. 535 */ 536 public boolean isInfoEnabled(Marker marker); 537 538 /** 539 * Log a message with the specific Marker at the INFO level. 540 * 541 * @param marker The marker specific to this log statement 542 * @param msg the message string to be logged 543 */ 544 public void info(Marker marker, String msg); 545 546 /** 547 * This method is similar to {@link #info(String, Object)} method except that the 548 * marker data is also taken into consideration. 549 * 550 * @param marker the marker data specific to this log statement 551 * @param format the format string 552 * @param arg the argument 553 */ 554 public void info(Marker marker, String format, Object arg); 555 556 /** 557 * This method is similar to {@link #info(String, Object, Object)} 558 * method except that the marker data is also taken into 559 * consideration. 560 * 561 * @param marker the marker data specific to this log statement 562 * @param format the format string 563 * @param arg1 the first argument 564 * @param arg2 the second argument 565 */ 566 public void info(Marker marker, String format, Object arg1, Object arg2); 567 568 /** 569 * This method is similar to {@link #info(String, Object...)} 570 * method except that the marker data is also taken into 571 * consideration. 572 * 573 * @param marker the marker data specific to this log statement 574 * @param format the format string 575 * @param arguments a list of 3 or more arguments 576 */ 577 public void info(Marker marker, String format, Object... arguments); 578 579 /** 580 * This method is similar to {@link #info(String, Throwable)} method 581 * except that the marker data is also taken into consideration. 582 * 583 * @param marker the marker data for this log statement 584 * @param msg the message accompanying the exception 585 * @param t the exception (throwable) to log 586 */ 587 public void info(Marker marker, String msg, Throwable t); 588 589 /** 590 * Entry point for fluent-logging for {@link org.slf4j.event.Level#INFO} level. 591 * 592 * <p>If this logger is disabled for the INFO level, then a {@link NOPLoggingEventBuilder} instance is returned. 593 * As the name indicates, this builder does not perform any operations. This is the main optimization in the fluent API.</p> 594 595 * @return LoggingEventBuilder instance as appropriate for level INFO 596 * @since 2.0 597 */ 598 @CheckReturnValue 599 default public LoggingEventBuilder atInfo() { 600 if (isInfoEnabled()) { 601 return makeLoggingEventBuilder(INFO); 602 } else { 603 return NOPLoggingEventBuilder.singleton(); 604 } 605 } 606 607 /** 608 * Is the logger instance enabled for the WARN level? 609 * 610 * @return True if this Logger is enabled for the WARN level, 611 * false otherwise. 612 */ 613 public boolean isWarnEnabled(); 614 615 /** 616 * Log a message at the WARN level. 617 * 618 * @param msg the message string to be logged 619 */ 620 public void warn(String msg); 621 622 /** 623 * Log a message at the WARN level according to the specified format 624 * and argument. 625 * 626 * <p>This form avoids superfluous object creation when the logger 627 * is disabled for the WARN level. 628 * 629 * @param format the format string 630 * @param arg the argument 631 */ 632 public void warn(String format, Object arg); 633 634 /** 635 * Log a message at the WARN level according to the specified format 636 * and arguments. 637 * 638 * <p>This form avoids superfluous string concatenation when the logger 639 * is disabled for the WARN level. However, this variant incurs the hidden 640 * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, 641 * even if this logger is disabled for WARN. The variants taking 642 * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two} 643 * arguments exist solely in order to avoid this hidden cost. 644 * 645 * @param format the format string 646 * @param arguments a list of 3 or more arguments 647 */ 648 public void warn(String format, Object... arguments); 649 650 /** 651 * Log a message at the WARN level according to the specified format 652 * and arguments. 653 * 654 * <p>This form avoids superfluous object creation when the logger 655 * is disabled for the WARN level. 656 * 657 * @param format the format string 658 * @param arg1 the first argument 659 * @param arg2 the second argument 660 */ 661 public void warn(String format, Object arg1, Object arg2); 662 663 /** 664 * Log an exception (throwable) at the WARN level with an 665 * accompanying message. 666 * 667 * @param msg the message accompanying the exception 668 * @param t the exception (throwable) to log 669 */ 670 public void warn(String msg, Throwable t); 671 672 /** 673 * Similar to {@link #isWarnEnabled()} method except that the marker 674 * data is also taken into consideration. 675 * 676 * @param marker The marker data to take into consideration 677 * @return True if this Logger is enabled for the WARN level, 678 * false otherwise. 679 */ 680 public boolean isWarnEnabled(Marker marker); 681 682 /** 683 * Log a message with the specific Marker at the WARN level. 684 * 685 * @param marker The marker specific to this log statement 686 * @param msg the message string to be logged 687 */ 688 public void warn(Marker marker, String msg); 689 690 /** 691 * This method is similar to {@link #warn(String, Object)} method except that the 692 * marker data is also taken into consideration. 693 * 694 * @param marker the marker data specific to this log statement 695 * @param format the format string 696 * @param arg the argument 697 */ 698 public void warn(Marker marker, String format, Object arg); 699 700 /** 701 * This method is similar to {@link #warn(String, Object, Object)} 702 * method except that the marker data is also taken into 703 * consideration. 704 * 705 * @param marker the marker data specific to this log statement 706 * @param format the format string 707 * @param arg1 the first argument 708 * @param arg2 the second argument 709 */ 710 public void warn(Marker marker, String format, Object arg1, Object arg2); 711 712 /** 713 * This method is similar to {@link #warn(String, Object...)} 714 * method except that the marker data is also taken into 715 * consideration. 716 * 717 * @param marker the marker data specific to this log statement 718 * @param format the format string 719 * @param arguments a list of 3 or more arguments 720 */ 721 public void warn(Marker marker, String format, Object... arguments); 722 723 /** 724 * This method is similar to {@link #warn(String, Throwable)} method 725 * except that the marker data is also taken into consideration. 726 * 727 * @param marker the marker data for this log statement 728 * @param msg the message accompanying the exception 729 * @param t the exception (throwable) to log 730 */ 731 public void warn(Marker marker, String msg, Throwable t); 732 733 /** 734 * Entry point for fluent-logging for {@link org.slf4j.event.Level#WARN} level. 735 * 736 * <p>If this logger is disabled for the WARN level, then a {@link NOPLoggingEventBuilder} instance is returned. 737 * As the name indicates, this builder does not perform any operations. This is the main optimization in the fluent API.</p> 738 * 739 * @return LoggingEventBuilder instance as appropriate for level WARN 740 * @since 2.0 741 */ 742 @CheckReturnValue 743 default public LoggingEventBuilder atWarn() { 744 if (isWarnEnabled()) { 745 return makeLoggingEventBuilder(WARN); 746 } else { 747 return NOPLoggingEventBuilder.singleton(); 748 } 749 } 750 751 /** 752 * Is the logger instance enabled for the ERROR level? 753 * 754 * @return True if this Logger is enabled for the ERROR level, 755 * false otherwise. 756 */ 757 public boolean isErrorEnabled(); 758 759 /** 760 * Log a message at the ERROR level. 761 * 762 * @param msg the message string to be logged 763 */ 764 public void error(String msg); 765 766 /** 767 * Log a message at the ERROR level according to the specified format 768 * and argument. 769 * 770 * <p>This form avoids superfluous object creation when the logger 771 * is disabled for the ERROR level. 772 * 773 * @param format the format string 774 * @param arg the argument 775 */ 776 public void error(String format, Object arg); 777 778 /** 779 * Log a message at the ERROR level according to the specified format 780 * and arguments. 781 * 782 * <p>This form avoids superfluous object creation when the logger 783 * is disabled for the ERROR level. 784 * 785 * @param format the format string 786 * @param arg1 the first argument 787 * @param arg2 the second argument 788 */ 789 public void error(String format, Object arg1, Object arg2); 790 791 /** 792 * Log a message at the ERROR level according to the specified format 793 * and arguments. 794 * 795 * <p>This form avoids superfluous string concatenation when the logger 796 * is disabled for the ERROR level. However, this variant incurs the hidden 797 * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, 798 * even if this logger is disabled for ERROR. The variants taking 799 * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two} 800 * arguments exist solely in order to avoid this hidden cost. 801 * 802 * @param format the format string 803 * @param arguments a list of 3 or more arguments 804 */ 805 public void error(String format, Object... arguments); 806 807 /** 808 * Log an exception (throwable) at the ERROR level with an 809 * accompanying message. 810 * 811 * @param msg the message accompanying the exception 812 * @param t the exception (throwable) to log 813 */ 814 public void error(String msg, Throwable t); 815 816 /** 817 * Similar to {@link #isErrorEnabled()} method except that the 818 * marker data is also taken into consideration. 819 * 820 * @param marker The marker data to take into consideration 821 * @return True if this Logger is enabled for the ERROR level, 822 * false otherwise. 823 */ 824 public boolean isErrorEnabled(Marker marker); 825 826 /** 827 * Log a message with the specific Marker at the ERROR level. 828 * 829 * @param marker The marker specific to this log statement 830 * @param msg the message string to be logged 831 */ 832 public void error(Marker marker, String msg); 833 834 /** 835 * This method is similar to {@link #error(String, Object)} method except that the 836 * marker data is also taken into consideration. 837 * 838 * @param marker the marker data specific to this log statement 839 * @param format the format string 840 * @param arg the argument 841 */ 842 public void error(Marker marker, String format, Object arg); 843 844 /** 845 * This method is similar to {@link #error(String, Object, Object)} 846 * method except that the marker data is also taken into 847 * consideration. 848 * 849 * @param marker the marker data specific to this log statement 850 * @param format the format string 851 * @param arg1 the first argument 852 * @param arg2 the second argument 853 */ 854 public void error(Marker marker, String format, Object arg1, Object arg2); 855 856 /** 857 * This method is similar to {@link #error(String, Object...)} 858 * method except that the marker data is also taken into 859 * consideration. 860 * 861 * @param marker the marker data specific to this log statement 862 * @param format the format string 863 * @param arguments a list of 3 or more arguments 864 */ 865 public void error(Marker marker, String format, Object... arguments); 866 867 /** 868 * This method is similar to {@link #error(String, Throwable)} 869 * method except that the marker data is also taken into 870 * consideration. 871 * 872 * @param marker the marker data specific to this log statement 873 * @param msg the message accompanying the exception 874 * @param t the exception (throwable) to log 875 */ 876 public void error(Marker marker, String msg, Throwable t); 877 878 /** 879 * Entry point for fluent-logging for {@link org.slf4j.event.Level#ERROR} level. 880 * 881 * <p>If this logger is disabled for the ERROR level, then a {@link NOPLoggingEventBuilder} instance is returned. 882 * As the name indicates, this builder does not perform any operations.</p> 883 * 884 * @return LoggingEventBuilder instance as appropriate for level ERROR 885 * @since 2.0 886 */ 887 @CheckReturnValue 888 default public LoggingEventBuilder atError() { 889 if (isErrorEnabled()) { 890 return makeLoggingEventBuilder(ERROR); 891 } else { 892 return NOPLoggingEventBuilder.singleton(); 893 } 894 } 895 896}