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