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