001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017 package org.apache.logging.log4j.spi; 018 019 import org.apache.logging.log4j.Level; 020 import org.apache.logging.log4j.Logger; 021 import org.apache.logging.log4j.Marker; 022 import org.apache.logging.log4j.MarkerManager; 023 import org.apache.logging.log4j.message.ParameterizedMessageFactory; 024 import org.apache.logging.log4j.message.Message; 025 import org.apache.logging.log4j.message.MessageFactory; 026 import org.apache.logging.log4j.status.StatusLogger; 027 028 /** 029 * Base implementation of a Logger. It is highly recommended that any Logger implementation extend this class. 030 * 031 */ 032 public abstract class AbstractLogger implements Logger { 033 /** 034 * Marker for flow tracing. 035 */ 036 public static final Marker FLOW_MARKER = MarkerManager.getMarker("FLOW"); 037 038 /** 039 * Marker for method entry tracing. 040 */ 041 public static final Marker ENTRY_MARKER = MarkerManager.getMarker("ENTRY", FLOW_MARKER); 042 043 /** 044 * Marker for method exit tracing. 045 */ 046 public static final Marker EXIT_MARKER = MarkerManager.getMarker("EXIT", FLOW_MARKER); 047 048 /** 049 * Marker for exception tracing. 050 */ 051 public static final Marker EXCEPTION_MARKER = MarkerManager.getMarker("EXCEPTION"); 052 053 /** 054 * Marker for throwing exceptions. 055 */ 056 public static final Marker THROWING_MARKER = MarkerManager.getMarker("THROWING", EXCEPTION_MARKER); 057 058 /** 059 * Marker for catching exceptions. 060 */ 061 public static final Marker CATCHING_MARKER = MarkerManager.getMarker("CATCHING", EXCEPTION_MARKER); 062 063 /** 064 * The default MessageFactory class. 065 */ 066 public static final Class<? extends MessageFactory> DEFAULT_MESSAGE_FACTORY_CLASS = 067 ParameterizedMessageFactory.class; 068 069 private static final String FQCN = AbstractLogger.class.getName(); 070 071 private static final String THROWING = "throwing"; 072 073 private static final String CATCHING = "catching"; 074 075 private final String name; 076 077 private final MessageFactory messageFactory; 078 079 /** 080 * Creates a new logger named after the class (or subclass). 081 */ 082 public AbstractLogger() { 083 this.name = getClass().getName(); 084 this.messageFactory = createDefaultMessageFactory(); 085 } 086 087 /** 088 * Creates a new named logger. 089 * 090 * @param name the logger name 091 */ 092 public AbstractLogger(final String name) { 093 this.name = name; 094 this.messageFactory = createDefaultMessageFactory(); 095 } 096 097 /** 098 * Creates a new named logger. 099 * 100 * @param name the logger name 101 * @param messageFactory the message factory, if null then use the default message factory. 102 */ 103 public AbstractLogger(final String name, final MessageFactory messageFactory) { 104 this.name = name; 105 this.messageFactory = messageFactory == null ? createDefaultMessageFactory() : messageFactory; 106 } 107 108 /** 109 * Checks that the message factory a logger was created with is the same as the given messageFactory. If they are 110 * different log a warning to the {@linkplain StatusLogger}. A null MessageFactory translates to the default 111 * MessageFactory {@link #DEFAULT_MESSAGE_FACTORY_CLASS}. 112 * 113 * @param logger 114 * The logger to check 115 * @param messageFactory 116 * The message factory to check. 117 */ 118 public static void checkMessageFactory(final Logger logger, final MessageFactory messageFactory) { 119 final String name = logger.getName(); 120 final MessageFactory loggerMessageFactory = logger.getMessageFactory(); 121 if (messageFactory != null && !loggerMessageFactory.equals(messageFactory)) { 122 StatusLogger 123 .getLogger() 124 .warn("The Logger {} was created with the message factory {} and is now requested with the " + 125 "message factory {}, which may create log events with unexpected formatting.", 126 name, loggerMessageFactory, messageFactory); 127 } else if (messageFactory == null 128 && !loggerMessageFactory.getClass().equals(DEFAULT_MESSAGE_FACTORY_CLASS)) { 129 StatusLogger 130 .getLogger() 131 .warn("The Logger {} was created with the message factory {} and is now requested with a null " + 132 "message factory (defaults to {}), which may create log events with unexpected formatting.", 133 name, loggerMessageFactory, DEFAULT_MESSAGE_FACTORY_CLASS.getName()); 134 } 135 } 136 137 private MessageFactory createDefaultMessageFactory() { 138 try { 139 return DEFAULT_MESSAGE_FACTORY_CLASS.newInstance(); 140 } catch (final InstantiationException e) { 141 throw new IllegalStateException(e); 142 } catch (final IllegalAccessException e) { 143 throw new IllegalStateException(e); 144 } 145 } 146 147 /** 148 * Logs entry to a method. 149 */ 150 public void entry() { 151 if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) { 152 log(ENTRY_MARKER, FQCN, Level.TRACE, messageFactory.newMessage(" entry"), null); 153 } 154 } 155 156 /** 157 * Logs entry to a method. 158 * 159 * @param params The parameters to the method. 160 */ 161 public void entry(final Object... params) { 162 if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) { 163 log(ENTRY_MARKER, FQCN, Level.TRACE, entryMsg(params.length, params), null); 164 } 165 } 166 167 /** 168 * Logs exit from a method. 169 */ 170 public void exit() { 171 if (isEnabled(Level.TRACE, EXIT_MARKER, (Object) null, null)) { 172 log(EXIT_MARKER, FQCN, Level.TRACE, toExitMsg(null), null); 173 } 174 } 175 176 /** 177 * Logs exiting from a method with the result. 178 * 179 * @param <R> The type of the parameter and object being returned. 180 * @param result The result being returned from the method call. 181 * @return the Throwable. 182 */ 183 public <R> R exit(final R result) { 184 if (isEnabled(Level.TRACE, EXIT_MARKER, (Object) null, null)) { 185 log(EXIT_MARKER, FQCN, Level.TRACE, toExitMsg(result), null); 186 } 187 return result; 188 } 189 190 /** 191 * Logs a Throwable to be thrown. 192 * 193 * @param <T> the type of the Throwable. 194 * @param t The Throwable. 195 * @return the Throwable. 196 */ 197 public <T extends Throwable> T throwing(final T t) { 198 if (isEnabled(Level.ERROR, THROWING_MARKER, (Object) null, null)) { 199 log(THROWING_MARKER, FQCN, Level.ERROR, messageFactory.newMessage(THROWING), t); 200 } 201 return t; 202 } 203 204 205 /** 206 * Logs a Throwable to be thrown. 207 * 208 * @param <T> the type of the Throwable. 209 * @param level The logging Level. 210 * @param t The Throwable. 211 * @return the Throwable. 212 */ 213 public <T extends Throwable> T throwing(final Level level, final T t) { 214 if (isEnabled(level, THROWING_MARKER, (Object) null, null)) { 215 log(THROWING_MARKER, FQCN, level, messageFactory.newMessage(THROWING), t); 216 } 217 return t; 218 } 219 220 /** 221 * Logs a Throwable at the {@link Level#ERROR ERROR} level.. 222 * 223 * @param t The Throwable. 224 */ 225 public void catching(final Throwable t) { 226 if (isEnabled(Level.ERROR, CATCHING_MARKER, (Object) null, null)) { 227 log(CATCHING_MARKER, FQCN, Level.ERROR, messageFactory.newMessage(CATCHING), t); 228 } 229 } 230 231 /** 232 * Logs a Throwable that has been caught. 233 * 234 * @param level The logging Level. 235 * @param t The Throwable. 236 */ 237 public void catching(final Level level, final Throwable t) { 238 if (isEnabled(level, CATCHING_MARKER, (Object) null, null)) { 239 log(CATCHING_MARKER, FQCN, level, messageFactory.newMessage(CATCHING), t); 240 } 241 } 242 243 /** 244 * Logs a message object with the {@link Level#TRACE TRACE} level. 245 * 246 * @param message the message object to log. 247 */ 248 public void trace(final String message) { 249 if (isEnabled(Level.TRACE, null, message)) { 250 log(null, FQCN, Level.TRACE, messageFactory.newMessage(message), null); 251 } 252 } 253 254 /** 255 * Logs a message object with the {@link Level#TRACE TRACE} level. 256 * 257 * @param marker the marker data specific to this log statement. 258 * @param message the message object to log. 259 */ 260 public void trace(final Marker marker, final String message) { 261 if (isEnabled(Level.TRACE, marker, message)) { 262 log(marker, FQCN, Level.TRACE, messageFactory.newMessage(message), null); 263 } 264 } 265 266 /** 267 * Logs a message at the {@link Level#TRACE TRACE} level including the 268 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 269 * <p/> 270 * <p> 271 * See {@link #debug(String)} form for more detailed information. 272 * </p> 273 * 274 * @param message the message object to log. 275 * @param t the exception to log, including its stack trace. 276 */ 277 public void trace(final String message, final Throwable t) { 278 if (isEnabled(Level.TRACE, null, message, t)) { 279 log(null, FQCN, Level.TRACE, messageFactory.newMessage(message), t); 280 } 281 } 282 283 /** 284 * Logs a message at the {@link Level#TRACE TRACE} level including the 285 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 286 * <p/> 287 * <p> 288 * See {@link #debug(String)} form for more detailed information. 289 * </p> 290 * 291 * @param marker the marker data specific to this log statement. 292 * @param message the message object to log. 293 * @param t the exception to log, including its stack trace. 294 */ 295 public void trace(final Marker marker, final String message, final Throwable t) { 296 if (isEnabled(Level.TRACE, marker, message, t)) { 297 log(marker, FQCN, Level.TRACE, messageFactory.newMessage(message), t); 298 } 299 } 300 301 /** 302 * Logs a message object with the {@link Level#TRACE TRACE} level. 303 * 304 * @param message the message object to log. 305 */ 306 public void trace(final Object message) { 307 if (isEnabled(Level.TRACE, null, message, null)) { 308 log(null, FQCN, Level.TRACE, messageFactory.newMessage(message), null); 309 } 310 } 311 312 /** 313 * Logs a message object with the {@link Level#TRACE TRACE} level. 314 * 315 * @param marker the marker data specific to this log statement. 316 * @param message the message object to log. 317 */ 318 public void trace(final Marker marker, final Object message) { 319 if (isEnabled(Level.TRACE, marker, message, null)) { 320 log(marker, FQCN, Level.TRACE, messageFactory.newMessage(message), null); 321 } 322 } 323 324 /** 325 * Logs a message at the {@link Level#TRACE TRACE} level including the 326 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 327 * <p/> 328 * <p> 329 * See {@link #debug(String)} form for more detailed information. 330 * </p> 331 * 332 * @param message the message object to log. 333 * @param t the exception to log, including its stack trace. 334 */ 335 public void trace(final Object message, final Throwable t) { 336 if (isEnabled(Level.TRACE, null, message, t)) { 337 log(null, FQCN, Level.TRACE, messageFactory.newMessage(message), t); 338 } 339 } 340 341 /** 342 * Logs a message at the {@link Level#TRACE TRACE} level including the 343 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 344 * <p/> 345 * <p> 346 * See {@link #debug(String)} form for more detailed information. 347 * </p> 348 * 349 * @param marker the marker data specific to this log statement. 350 * @param message the message object to log. 351 * @param t the exception to log, including its stack trace. 352 */ 353 public void trace(final Marker marker, final Object message, final Throwable t) { 354 if (isEnabled(Level.TRACE, marker, message, t)) { 355 log(marker, FQCN, Level.TRACE, messageFactory.newMessage(message), t); 356 } 357 } 358 359 /** 360 * Logs a message with parameters at the {@link Level#TRACE TRACE} level. 361 * 362 * @param message the message to log. 363 * @param params parameters to the message. 364 */ 365 public void trace(final String message, final Object... params) { 366 if (isEnabled(Level.TRACE, null, message, params)) { 367 final Message msg = messageFactory.newMessage(message, params); 368 log(null, FQCN, Level.TRACE, msg, msg.getThrowable()); 369 } 370 } 371 372 /** 373 * Logs a message with parameters at the {@link Level#TRACE TRACE} level. 374 * 375 * @param marker the marker data specific to this log statement. 376 * @param message the message to log. 377 * @param params parameters to the message. 378 */ 379 public void trace(final Marker marker, final String message, final Object... params) { 380 if (isEnabled(Level.TRACE, marker, message, params)) { 381 final Message msg = messageFactory.newMessage(message, params); 382 log(marker, FQCN, Level.TRACE, msg, msg.getThrowable()); 383 } 384 } 385 386 /** 387 * Checks whether this Logger is enabled for the TRACE Level. 388 * 389 * @return boolean - {@code true} if this Logger is enabled for level 390 * TRACE, {@code false} otherwise. 391 */ 392 public boolean isTraceEnabled() { 393 return isEnabled(Level.TRACE, null, (Object) null, null); 394 } 395 396 /** 397 * Checks whether this Logger is enabled for the TRACE Level. 398 * 399 * @param marker The marker data. 400 * @return boolean - {@code true} if this Logger is enabled for level 401 * TRACE, {@code false} otherwise. 402 */ 403 public boolean isTraceEnabled(final Marker marker) { 404 return isEnabled(Level.TRACE, marker, (Object) null, null); 405 } 406 407 /** 408 * Logs a message with the specific Marker at the TRACE level. 409 * 410 * @param msg the message string to be logged 411 */ 412 public void trace(final Message msg) { 413 if (isEnabled(Level.TRACE, null, msg, null)) { 414 log(null, FQCN, Level.TRACE, msg, null); 415 } 416 } 417 418 /** 419 * Logs a message with the specific Marker at the TRACE level. 420 * 421 * @param msg the message string to be logged 422 * @param t A Throwable or null. 423 */ 424 public void trace(final Message msg, final Throwable t) { 425 if (isEnabled(Level.TRACE, null, msg, t)) { 426 log(null, FQCN, Level.TRACE, msg, t); 427 } 428 } 429 430 /** 431 * Logs a message with the specific Marker at the TRACE level. 432 * 433 * @param marker the marker data specific to this log statement. 434 * @param msg the message string to be logged 435 */ 436 public void trace(final Marker marker, final Message msg) { 437 if (isEnabled(Level.TRACE, marker, msg, null)) { 438 log(marker, FQCN, Level.TRACE, msg, null); 439 } 440 } 441 442 /** 443 * Logs a message with the specific Marker at the TRACE level. 444 * 445 * @param marker the marker data specific to this log statement. 446 * @param msg the message string to be logged 447 * @param t A Throwable or null. 448 */ 449 public void trace(final Marker marker, final Message msg, final Throwable t) { 450 if (isEnabled(Level.TRACE, marker, msg, t)) { 451 log(marker, FQCN, Level.TRACE, msg, t); 452 } 453 } 454 455 /** 456 * Logs a message object with the {@link Level#DEBUG DEBUG} level. 457 * 458 * @param message the message object to log. 459 */ 460 public void debug(final String message) { 461 if (isEnabled(Level.DEBUG, null, message)) { 462 log(null, FQCN, Level.DEBUG, messageFactory.newMessage(message), null); 463 } 464 } 465 466 /** 467 * Logs a message object with the {@link Level#DEBUG DEBUG} level. 468 * 469 * @param marker the marker data specific to this log statement. 470 * @param message the message object to log. 471 */ 472 public void debug(final Marker marker, final String message) { 473 if (isEnabled(Level.DEBUG, marker, message)) { 474 log(marker, FQCN, Level.DEBUG, messageFactory.newMessage(message), null); 475 } 476 } 477 478 /** 479 * Logs a message at the {@link Level#DEBUG DEBUG} level including the 480 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 481 * 482 * @param message the message to log. 483 * @param t the exception to log, including its stack trace. 484 */ 485 public void debug(final String message, final Throwable t) { 486 if (isEnabled(Level.DEBUG, null, message, t)) { 487 log(null, FQCN, Level.DEBUG, messageFactory.newMessage(message), t); 488 } 489 } 490 491 /** 492 * Logs a message at the {@link Level#DEBUG DEBUG} level including the 493 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 494 * 495 * @param marker the marker data specific to this log statement. 496 * @param message the message to log. 497 * @param t the exception to log, including its stack trace. 498 */ 499 public void debug(final Marker marker, final String message, final Throwable t) { 500 if (isEnabled(Level.DEBUG, marker, message, t)) { 501 log(marker, FQCN, Level.DEBUG, messageFactory.newMessage(message), t); 502 } 503 } 504 /** 505 * Logs a message object with the {@link Level#DEBUG DEBUG} level. 506 * 507 * @param message the message object to log. 508 */ 509 public void debug(final Object message) { 510 if (isEnabled(Level.DEBUG, null, message, null)) { 511 log(null, FQCN, Level.DEBUG, messageFactory.newMessage(message), null); 512 } 513 } 514 515 /** 516 * Logs a message object with the {@link Level#DEBUG DEBUG} level. 517 * 518 * @param marker the marker data specific to this log statement. 519 * @param message the message object to log. 520 */ 521 public void debug(final Marker marker, final Object message) { 522 if (isEnabled(Level.DEBUG, marker, message, null)) { 523 log(marker, FQCN, Level.DEBUG, messageFactory.newMessage(message), null); 524 } 525 } 526 527 /** 528 * Logs a message at the {@link Level#DEBUG DEBUG} level including the 529 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 530 * 531 * @param message the message to log. 532 * @param t the exception to log, including its stack trace. 533 */ 534 public void debug(final Object message, final Throwable t) { 535 if (isEnabled(Level.DEBUG, null, message, t)) { 536 log(null, FQCN, Level.DEBUG, messageFactory.newMessage(message), t); 537 } 538 } 539 540 /** 541 * Logs a message at the {@link Level#DEBUG DEBUG} level including the 542 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 543 * 544 * @param marker the marker data specific to this log statement. 545 * @param message the message to log. 546 * @param t the exception to log, including its stack trace. 547 */ 548 public void debug(final Marker marker, final Object message, final Throwable t) { 549 if (isEnabled(Level.DEBUG, marker, message, t)) { 550 log(marker, FQCN, Level.DEBUG, messageFactory.newMessage(message), t); 551 } 552 } 553 554 /** 555 * Logs a message with parameters at the {@link Level#DEBUG DEBUG} level. 556 * 557 * @param message the message to log. 558 * @param params parameters to the message. 559 */ 560 public void debug(final String message, final Object... params) { 561 if (isEnabled(Level.DEBUG, null, message, params)) { 562 final Message msg = messageFactory.newMessage(message, params); 563 log(null, FQCN, Level.DEBUG, msg, msg.getThrowable()); 564 } 565 } 566 567 /** 568 * Logs a message with parameters at the {@link Level#DEBUG DEBUG} level. 569 * 570 * @param marker the marker data specific to this log statement. 571 * @param message the message to log. 572 * @param params parameters to the message. 573 */ 574 public void debug(final Marker marker, final String message, final Object... params) { 575 if (isEnabled(Level.DEBUG, marker, message, params)) { 576 final Message msg = messageFactory.newMessage(message, params); 577 log(marker, FQCN, Level.DEBUG, msg, msg.getThrowable()); 578 } 579 } 580 581 /** 582 * Checks whether this Logger is enabled for the DEBUG Level. 583 * 584 * @return boolean - {@code true} if this Logger is enabled for level 585 * DEBUG, {@code false} otherwise. 586 */ 587 public boolean isDebugEnabled() { 588 return isEnabled(Level.DEBUG, null, null); 589 } 590 591 /** 592 * Checks whether this Logger is enabled for the DEBUG Level. 593 * 594 * @param marker The marker data. 595 * @return boolean - {@code true} if this Logger is enabled for level 596 * DEBUG, {@code false} otherwise. 597 */ 598 public boolean isDebugEnabled(final Marker marker) { 599 return isEnabled(Level.DEBUG, marker, (Object) null, null); 600 } 601 602 /** 603 * Logs a message with the specific Marker at the DEBUG level. 604 * 605 * @param msg the message string to be logged 606 */ 607 public void debug(final Message msg) { 608 if (isEnabled(Level.DEBUG, null, msg, null)) { 609 log(null, FQCN, Level.DEBUG, msg, null); 610 } 611 } 612 613 /** 614 * Logs a message with the specific Marker at the DEBUG level. 615 * 616 * @param msg the message string to be logged 617 * @param t A Throwable or null. 618 */ 619 public void debug(final Message msg, final Throwable t) { 620 if (isEnabled(Level.DEBUG, null, msg, t)) { 621 log(null, FQCN, Level.DEBUG, msg, t); 622 } 623 } 624 625 /** 626 * Logs a message with the specific Marker at the DEBUG level. 627 * 628 * @param marker the marker data specific to this log statement 629 * @param msg the message string to be logged 630 */ 631 public void debug(final Marker marker, final Message msg) { 632 if (isEnabled(Level.DEBUG, marker, msg, null)) { 633 log(marker, FQCN, Level.DEBUG, msg, null); 634 } 635 } 636 637 /** 638 * Logs a message with the specific Marker at the DEBUG level. 639 * 640 * @param marker the marker data specific to this log statement. 641 * @param msg the message string to be logged 642 * @param t A Throwable or null. 643 */ 644 public void debug(final Marker marker, final Message msg, final Throwable t) { 645 if (isEnabled(Level.DEBUG, marker, msg, t)) { 646 log(marker, FQCN, Level.DEBUG, msg, t); 647 } 648 } 649 650 /** 651 * Logs a message object with the {@link Level#INFO INFO} level. 652 * 653 * @param message the message object to log. 654 */ 655 public void info(final String message) { 656 if (isEnabled(Level.INFO, null, message)) { 657 log(null, FQCN, Level.INFO, messageFactory.newMessage(message), null); 658 } 659 } 660 661 /** 662 * Logs a message object with the {@link Level#INFO INFO} level. 663 * 664 * @param marker the marker data specific to this log statement. 665 * @param message the message object to log. 666 */ 667 public void info(final Marker marker, final String message) { 668 if (isEnabled(Level.INFO, marker, message)) { 669 log(marker, FQCN, Level.INFO, messageFactory.newMessage(message), null); 670 } 671 } 672 673 /** 674 * Logs a message at the {@link Level#INFO INFO} level including the 675 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 676 * 677 * @param message the message object to log. 678 * @param t the exception to log, including its stack trace. 679 */ 680 public void info(final String message, final Throwable t) { 681 if (isEnabled(Level.INFO, null, message, t)) { 682 log(null, FQCN, Level.INFO, messageFactory.newMessage(message), t); 683 } 684 } 685 686 /** 687 * Logs a message at the {@link Level#INFO INFO} level including the 688 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 689 * 690 * @param marker the marker data specific to this log statement. 691 * @param message the message object to log. 692 * @param t the exception to log, including its stack trace. 693 */ 694 public void info(final Marker marker, final String message, final Throwable t) { 695 if (isEnabled(Level.INFO, marker, message, t)) { 696 log(marker, FQCN, Level.INFO, messageFactory.newMessage(message), t); 697 } 698 } 699 700 /** 701 * Logs a message object with the {@link Level#INFO INFO} level. 702 * 703 * @param message the message object to log. 704 */ 705 public void info(final Object message) { 706 if (isEnabled(Level.INFO, null, message, null)) { 707 log(null, FQCN, Level.INFO, messageFactory.newMessage(message), null); 708 } 709 } 710 711 /** 712 * Logs a message object with the {@link Level#INFO INFO} level. 713 * 714 * @param marker the marker data specific to this log statement. 715 * @param message the message object to log. 716 */ 717 public void info(final Marker marker, final Object message) { 718 if (isEnabled(Level.INFO, marker, message, null)) { 719 log(marker, FQCN, Level.INFO, messageFactory.newMessage(message), null); 720 } 721 } 722 723 /** 724 * Logs a message at the {@link Level#INFO INFO} level including the 725 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 726 * 727 * @param message the message object to log. 728 * @param t the exception to log, including its stack trace. 729 */ 730 public void info(final Object message, final Throwable t) { 731 if (isEnabled(Level.INFO, null, message, t)) { 732 log(null, FQCN, Level.INFO, messageFactory.newMessage(message), t); 733 } 734 } 735 736 737 /** 738 * Logs a message at the {@link Level#INFO INFO} level including the 739 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 740 * 741 * @param marker the marker data specific to this log statement. 742 * @param message the message object to log. 743 * @param t the exception to log, including its stack trace. 744 */ 745 public void info(final Marker marker, final Object message, final Throwable t) { 746 if (isEnabled(Level.INFO, marker, message, t)) { 747 log(marker, FQCN, Level.INFO, messageFactory.newMessage(message), t); 748 } 749 } 750 751 /** 752 * Logs a message with parameters at the {@link Level#INFO INFO} level. 753 * 754 * @param message the message to log. 755 * @param params parameters to the message. 756 */ 757 public void info(final String message, final Object... params) { 758 if (isEnabled(Level.INFO, null, message, params)) { 759 final Message msg = messageFactory.newMessage(message, params); 760 log(null, FQCN, Level.INFO, msg, msg.getThrowable()); 761 } 762 } 763 764 /** 765 * Logs a message with parameters at the {@link Level#INFO INFO} level. 766 * 767 * @param marker the marker data specific to this log statement. 768 * @param message the message to log. 769 * @param params parameters to the message. 770 */ 771 public void info(final Marker marker, final String message, final Object... params) { 772 if (isEnabled(Level.INFO, marker, message, params)) { 773 final Message msg = messageFactory.newMessage(message, params); 774 log(marker, FQCN, Level.INFO, msg, msg.getThrowable()); 775 } 776 } 777 778 /** 779 * Checks whether this Logger is enabled for the INFO Level. 780 * 781 * @return boolean - {@code true} if this Logger is enabled for level 782 * INFO, {@code false} otherwise. 783 */ 784 public boolean isInfoEnabled() { 785 return isEnabled(Level.INFO, null, (Object) null, null); 786 } 787 788 /** 789 * Checks whether this Logger is enabled for the INFO Level. 790 * @param marker The marker data. 791 * @return boolean - {@code true} if this Logger is enabled for level 792 * INFO, {@code false} otherwise. 793 */ 794 public boolean isInfoEnabled(final Marker marker) { 795 return isEnabled(Level.INFO, marker, (Object) null, null); 796 } 797 798 /** 799 * Logs a message with the specific Marker at the TRACE level. 800 * 801 * @param msg the message string to be logged 802 */ 803 public void info(final Message msg) { 804 if (isEnabled(Level.INFO, null, msg, null)) { 805 log(null, FQCN, Level.INFO, msg, null); 806 } 807 } 808 809 /** 810 * Logs a message with the specific Marker at the INFO level. 811 * 812 * @param msg the message string to be logged 813 * @param t A Throwable or null. 814 */ 815 public void info(final Message msg, final Throwable t) { 816 if (isEnabled(Level.INFO, null, msg, t)) { 817 log(null, FQCN, Level.INFO, msg, t); 818 } 819 } 820 821 /** 822 * Logs a message with the specific Marker at the INFO level. 823 * 824 * @param marker the marker data specific to this log statement 825 * @param msg the message string to be logged 826 */ 827 public void info(final Marker marker, final Message msg) { 828 if (isEnabled(Level.INFO, marker, msg, null)) { 829 log(marker, FQCN, Level.INFO, msg, null); 830 } 831 } 832 833 /** 834 * Logs a message with the specific Marker at the INFO level. 835 * 836 * @param marker the marker data specific to this log statement 837 * @param msg the message string to be logged 838 * @param t A Throwable or null. 839 */ 840 public void info(final Marker marker, final Message msg, final Throwable t) { 841 if (isEnabled(Level.INFO, marker, msg, t)) { 842 log(marker, FQCN, Level.INFO, msg, t); 843 } 844 } 845 846 /** 847 * Logs a message object with the {@link Level#WARN WARN} level. 848 * 849 * @param message the message object to log. 850 */ 851 public void warn(final String message) { 852 if (isEnabled(Level.WARN, null, message)) { 853 log(null, FQCN, Level.WARN, messageFactory.newMessage(message), null); 854 } 855 } 856 857 /** 858 * Logs a message object with the {@link Level#WARN WARN} level. 859 * 860 * @param marker the marker data specific to this log statement. 861 * @param message the message object to log. 862 */ 863 public void warn(final Marker marker, final String message) { 864 if (isEnabled(Level.WARN, marker, message)) { 865 log(marker, FQCN, Level.WARN, messageFactory.newMessage(message), null); 866 } 867 } 868 869 /** 870 * Logs a message at the {@link Level#WARN WARN} level including the 871 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 872 * 873 * @param message the message object to log. 874 * @param t the exception to log, including its stack trace. 875 */ 876 public void warn(final String message, final Throwable t) { 877 if (isEnabled(Level.WARN, null, message, t)) { 878 log(null, FQCN, Level.WARN, messageFactory.newMessage(message), t); 879 } 880 } 881 882 /** 883 * Logs a message at the {@link Level#WARN WARN} level including the 884 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 885 * 886 * @param marker the marker data specific to this log statement. 887 * @param message the message object to log. 888 * @param t the exception to log, including its stack trace. 889 */ 890 public void warn(final Marker marker, final String message, final Throwable t) { 891 if (isEnabled(Level.WARN, marker, message, t)) { 892 log(marker, FQCN, Level.WARN, messageFactory.newMessage(message), t); 893 } 894 } 895 896 /** 897 * Logs a message object with the {@link Level#WARN WARN} level. 898 * 899 * @param marker the marker data specific to this log statement. 900 * @param message the message object to log. 901 */ 902 public void warn(final Marker marker, final Object message) { 903 if (isEnabled(Level.WARN, marker, message, null)) { 904 log(marker, FQCN, Level.WARN, messageFactory.newMessage(message), null); 905 } 906 } 907 908 /** 909 * Logs a message object with the {@link Level#WARN WARN} level. 910 * 911 * @param message the message object to log. 912 */ 913 public void warn(final Object message) { 914 if (isEnabled(Level.WARN, null, message, null)) { 915 log(null, FQCN, Level.WARN, messageFactory.newMessage(message), null); 916 } 917 } 918 919 /** 920 * Logs a message at the {@link Level#WARN WARN} level including the 921 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 922 * 923 * @param message the message object to log. 924 * @param t the exception to log, including its stack trace. 925 */ 926 public void warn(final Object message, final Throwable t) { 927 if (isEnabled(Level.WARN, null, message, t)) { 928 log(null, FQCN, Level.WARN, messageFactory.newMessage(message), t); 929 } 930 } 931 932 /** 933 * Logs a message at the {@link Level#WARN WARN} level including the 934 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 935 * 936 * @param marker the marker data specific to this log statement. 937 * @param message the message object to log. 938 * @param t the exception to log, including its stack trace. 939 */ 940 public void warn(final Marker marker, final Object message, final Throwable t) { 941 if (isEnabled(Level.WARN, marker, message, t)) { 942 log(marker, FQCN, Level.WARN, messageFactory.newMessage(message), t); 943 } 944 } 945 946 /** 947 * Logs a message with parameters at the {@link Level#WARN WARN} level. 948 * 949 * @param message the message to log. 950 * @param params parameters to the message. 951 */ 952 public void warn(final String message, final Object... params) { 953 if (isEnabled(Level.WARN, null, message, params)) { 954 final Message msg = messageFactory.newMessage(message, params); 955 log(null, FQCN, Level.WARN, msg, msg.getThrowable()); 956 } 957 } 958 959 /** 960 * Logs a message with parameters at the {@link Level#WARN WARN} level. 961 * 962 * @param marker the marker data specific to this log statement. 963 * @param message the message to log. 964 * @param params parameters to the message. 965 */ 966 public void warn(final Marker marker, final String message, final Object... params) { 967 if (isEnabled(Level.WARN, marker, message, params)) { 968 final Message msg = messageFactory.newMessage(message, params); 969 log(marker, FQCN, Level.WARN, msg, msg.getThrowable()); 970 } 971 } 972 973 /** 974 * Checks whether this Logger is enabled for the WARN Level. 975 * 976 * @return boolean - {@code true} if this Logger is enabled for level 977 * WARN, {@code false} otherwise. 978 */ 979 public boolean isWarnEnabled() { 980 return isEnabled(Level.WARN, null, (Object) null, null); 981 } 982 983 984 /** 985 * Checks whether this Logger is enabled for the WARN Level. 986 * 987 * @param marker The marker data. 988 * @return boolean - {@code true} if this Logger is enabled for level 989 * WARN, {@code false} otherwise. 990 */ 991 public boolean isWarnEnabled(final Marker marker) { 992 return isEnabled(Level.WARN, marker, (Object) null, null); 993 } 994 995 /** 996 * Logs a message with the specific Marker at the WARN level. 997 * 998 * @param msg the message string to be logged 999 */ 1000 public void warn(final Message msg) { 1001 if (isEnabled(Level.WARN, null, msg, null)) { 1002 log(null, FQCN, Level.WARN, msg, null); 1003 } 1004 } 1005 1006 /** 1007 * Logs a message with the specific Marker at the WARN level. 1008 * 1009 * @param msg the message string to be logged 1010 * @param t A Throwable or null. 1011 */ 1012 public void warn(final Message msg, final Throwable t) { 1013 if (isEnabled(Level.WARN, null, msg, t)) { 1014 log(null, FQCN, Level.WARN, msg, t); 1015 } 1016 } 1017 1018 /** 1019 * Logs a message with the specific Marker at the WARN level. 1020 * 1021 * @param marker the marker data specific to this log statement 1022 * @param msg the message string to be logged 1023 */ 1024 public void warn(final Marker marker, final Message msg) { 1025 if (isEnabled(Level.WARN, marker, msg, null)) { 1026 log(marker, FQCN, Level.WARN, msg, null); 1027 } 1028 } 1029 1030 /** 1031 * Logs a message with the specific Marker at the WARN level. 1032 * 1033 * @param marker the marker data specific to this log statement 1034 * @param msg the message string to be logged 1035 * @param t A Throwable or null. 1036 */ 1037 public void warn(final Marker marker, final Message msg, final Throwable t) { 1038 if (isEnabled(Level.WARN, marker, msg, t)) { 1039 log(marker, FQCN, Level.WARN, msg, t); 1040 } 1041 } 1042 1043 /** 1044 * Logs a message object with the {@link Level#ERROR ERROR} level. 1045 * 1046 * @param message the message object to log. 1047 */ 1048 public void error(final String message) { 1049 if (isEnabled(Level.ERROR, null, message)) { 1050 log(null, FQCN, Level.ERROR, messageFactory.newMessage(message), null); 1051 } 1052 } 1053 1054 /** 1055 * Logs a message object with the {@link Level#ERROR ERROR} level. 1056 * 1057 * @param marker the marker data specific to this log statement. 1058 * @param message the message object to log. 1059 */ 1060 public void error(final Marker marker, final String message) { 1061 if (isEnabled(Level.ERROR, marker, message)) { 1062 log(marker, FQCN, Level.ERROR, messageFactory.newMessage(message), null); 1063 } 1064 } 1065 1066 /** 1067 * Logs a message at the {@link Level#ERROR ERROR} level including the 1068 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1069 * 1070 * @param message the message object to log. 1071 * @param t the exception to log, including its stack trace. 1072 */ 1073 public void error(final String message, final Throwable t) { 1074 if (isEnabled(Level.ERROR, null, message, t)) { 1075 log(null, FQCN, Level.ERROR, messageFactory.newMessage(message), t); 1076 } 1077 } 1078 1079 /** 1080 * Logs a message at the {@link Level#ERROR ERROR} level including the 1081 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1082 * 1083 * @param marker the marker data specific to this log statement. 1084 * @param message the message object to log. 1085 * @param t the exception to log, including its stack trace. 1086 */ 1087 public void error(final Marker marker, final String message, final Throwable t) { 1088 if (isEnabled(Level.ERROR, marker, message, t)) { 1089 log(marker, FQCN, Level.ERROR, messageFactory.newMessage(message), t); 1090 } 1091 } 1092 1093 /** 1094 * Logs a message object with the {@link Level#ERROR ERROR} level. 1095 * 1096 * @param message the message object to log. 1097 */ 1098 public void error(final Object message) { 1099 if (isEnabled(Level.ERROR, null, message, null)) { 1100 log(null, FQCN, Level.ERROR, messageFactory.newMessage(message), null); 1101 } 1102 } 1103 1104 /** 1105 * Logs a message object with the {@link Level#ERROR ERROR} level. 1106 * 1107 * @param marker the marker data specific to this log statement. 1108 * @param message the message object to log. 1109 */ 1110 public void error(final Marker marker, final Object message) { 1111 if (isEnabled(Level.ERROR, marker, message, null)) { 1112 log(marker, FQCN, Level.ERROR, messageFactory.newMessage(message), null); 1113 } 1114 } 1115 1116 /** 1117 * Logs a message at the {@link Level#ERROR ERROR} level including the 1118 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1119 * 1120 * @param message the message object to log. 1121 * @param t the exception to log, including its stack trace. 1122 */ 1123 public void error(final Object message, final Throwable t) { 1124 if (isEnabled(Level.ERROR, null, message, t)) { 1125 log(null, FQCN, Level.ERROR, messageFactory.newMessage(message), t); 1126 } 1127 } 1128 1129 /** 1130 * Logs a message at the {@link Level#ERROR ERROR} level including the 1131 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1132 * 1133 * @param marker the marker data specific to this log statement. 1134 * @param message the message object to log. 1135 * @param t the exception to log, including its stack trace. 1136 */ 1137 public void error(final Marker marker, final Object message, final Throwable t) { 1138 if (isEnabled(Level.ERROR, marker, message, t)) { 1139 log(marker, FQCN, Level.ERROR, messageFactory.newMessage(message), t); 1140 } 1141 } 1142 1143 /** 1144 * Logs a message with parameters at the {@link Level#ERROR ERROR} level. 1145 * 1146 * @param message the message to log. 1147 * @param params parameters to the message. 1148 */ 1149 public void error(final String message, final Object... params) { 1150 if (isEnabled(Level.ERROR, null, message, params)) { 1151 final Message msg = messageFactory.newMessage(message, params); 1152 log(null, FQCN, Level.ERROR, msg, msg.getThrowable()); 1153 } 1154 } 1155 1156 /** 1157 * Logs a message with parameters at the {@link Level#ERROR ERROR} level. 1158 * 1159 * @param marker the marker data specific to this log statement. 1160 * @param message the message to log. 1161 * @param params parameters to the message. 1162 */ 1163 public void error(final Marker marker, final String message, final Object... params) { 1164 if (isEnabled(Level.ERROR, marker, message, params)) { 1165 final Message msg = messageFactory.newMessage(message, params); 1166 log(marker, FQCN, Level.ERROR, msg, msg.getThrowable()); 1167 } 1168 } 1169 1170 1171 /** 1172 * Checks whether this Logger is enabled for the {@link Level#ERROR ERROR} Level. 1173 * 1174 * @return boolean - {@code true} if this Logger is enabled for level 1175 * {@link Level#ERROR ERROR}, {@code false} otherwise. 1176 */ 1177 public boolean isErrorEnabled() { 1178 return isEnabled(Level.ERROR, null, (Object) null, null); 1179 } 1180 1181 /** 1182 * Checks whether this Logger is enabled for the {@link Level#ERROR ERROR} Level. 1183 * 1184 * @param marker The marker data. 1185 * @return boolean - {@code true} if this Logger is enabled for level 1186 * {@link Level#ERROR ERROR}, {@code false} otherwise. 1187 */ 1188 public boolean isErrorEnabled(final Marker marker) { 1189 return isEnabled(Level.ERROR, marker, (Object) null, null); 1190 } 1191 1192 /** 1193 * Logs a message with the specific Marker at the {@link Level#ERROR ERROR} level. 1194 * 1195 * @param msg the message string to be logged 1196 */ 1197 public void error(final Message msg) { 1198 if (isEnabled(Level.ERROR, null, msg, null)) { 1199 log(null, FQCN, Level.ERROR, msg, null); 1200 } 1201 } 1202 1203 /** 1204 * Logs a message with the specific Marker at the {@link Level#ERROR ERROR} level. 1205 * 1206 * @param msg the message string to be logged 1207 * @param t A Throwable or null. 1208 */ 1209 public void error(final Message msg, final Throwable t) { 1210 if (isEnabled(Level.ERROR, null, msg, t)) { 1211 log(null, FQCN, Level.ERROR, msg, t); 1212 } 1213 } 1214 1215 /** 1216 * Logs a message with the specific Marker at the {@link Level#ERROR ERROR} level. 1217 * 1218 * @param marker the marker data specific to this log statement 1219 * @param msg the message string to be logged 1220 */ 1221 public void error(final Marker marker, final Message msg) { 1222 if (isEnabled(Level.ERROR, marker, msg, null)) { 1223 log(marker, FQCN, Level.ERROR, msg, null); 1224 } 1225 } 1226 1227 /** 1228 * Logs a message with the specific Marker at the {@link Level#ERROR ERROR} level. 1229 * 1230 * @param marker the marker data specific to this log statement 1231 * @param msg the message string to be logged 1232 * @param t A Throwable or null. 1233 */ 1234 public void error(final Marker marker, final Message msg, final Throwable t) { 1235 if (isEnabled(Level.ERROR, marker, msg, t)) { 1236 log(marker, FQCN, Level.ERROR, msg, t); 1237 } 1238 } 1239 1240 /** 1241 * Logs a message object with the {@link Level#FATAL FATAL} level. 1242 * 1243 * @param message the message object to log. 1244 */ 1245 public void fatal(final String message) { 1246 if (isEnabled(Level.FATAL, null, message)) { 1247 log(null, FQCN, Level.FATAL, messageFactory.newMessage(message), null); 1248 } 1249 } 1250 1251 1252 /** 1253 * Logs a message object with the {@link Level#FATAL FATAL} level. 1254 * 1255 * @param marker the marker data specific to this log statement. 1256 * @param message the message object to log. 1257 */ 1258 public void fatal(final Marker marker, final String message) { 1259 if (isEnabled(Level.FATAL, marker, message)) { 1260 log(marker, FQCN, Level.FATAL, messageFactory.newMessage(message), null); 1261 } 1262 } 1263 1264 /** 1265 * Logs a message at the {@link Level#FATAL FATAL} level including the 1266 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1267 * 1268 * @param message the message object to log. 1269 * @param t the exception to log, including its stack trace. 1270 */ 1271 public void fatal(final String message, final Throwable t) { 1272 if (isEnabled(Level.FATAL, null, message, t)) { 1273 log(null, FQCN, Level.FATAL, messageFactory.newMessage(message), t); 1274 } 1275 } 1276 1277 /** 1278 * Logs a message at the {@link Level#FATAL FATAL} level including the 1279 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1280 * 1281 * @param marker the marker data specific to this log statement. 1282 * @param message the message object to log. 1283 * @param t the exception to log, including its stack trace. 1284 */ 1285 public void fatal(final Marker marker, final String message, final Throwable t) { 1286 if (isEnabled(Level.FATAL, marker, message, t)) { 1287 log(marker, FQCN, Level.FATAL, messageFactory.newMessage(message), t); 1288 } 1289 } 1290 1291 /** 1292 * Logs a message object with the {@link Level#FATAL FATAL} level. 1293 * 1294 * @param message the message object to log. 1295 */ 1296 public void fatal(final Object message) { 1297 if (isEnabled(Level.FATAL, null, message, null)) { 1298 log(null, FQCN, Level.FATAL, messageFactory.newMessage(message), null); 1299 } 1300 } 1301 1302 /** 1303 * Logs a message object with the {@link Level#FATAL FATAL} level. 1304 * 1305 * @param marker the marker data specific to this log statement. 1306 * @param message the message object to log. 1307 */ 1308 public void fatal(final Marker marker, final Object message) { 1309 if (isEnabled(Level.FATAL, marker, message, null)) { 1310 log(marker, FQCN, Level.FATAL, messageFactory.newMessage(message), null); 1311 } 1312 } 1313 1314 /** 1315 * Logs a message at the {@link Level#FATAL FATAL} level including the 1316 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1317 * 1318 * @param message the message object to log. 1319 * @param t the exception to log, including its stack trace. 1320 */ 1321 public void fatal(final Object message, final Throwable t) { 1322 if (isEnabled(Level.FATAL, null, message, t)) { 1323 log(null, FQCN, Level.FATAL, messageFactory.newMessage(message), t); 1324 } 1325 } 1326 1327 /** 1328 * Logs a message at the {@link Level#FATAL FATAL} level including the 1329 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1330 * 1331 * @param marker the marker data specific to this log statement. 1332 * @param message the message object to log. 1333 * @param t the exception to log, including its stack trace. 1334 */ 1335 public void fatal(final Marker marker, final Object message, final Throwable t) { 1336 if (isEnabled(Level.FATAL, marker, message, t)) { 1337 log(marker, FQCN, Level.FATAL, messageFactory.newMessage(message), t); 1338 } 1339 } 1340 1341 /** 1342 * Logs a message with parameters at the {@link Level#FATAL FATAL} level. 1343 * 1344 * @param message the message to log. 1345 * @param params parameters to the message. 1346 */ 1347 public void fatal(final String message, final Object... params) { 1348 if (isEnabled(Level.FATAL, null, message, params)) { 1349 final Message msg = messageFactory.newMessage(message, params); 1350 log(null, FQCN, Level.FATAL, msg, msg.getThrowable()); 1351 } 1352 } 1353 1354 /** 1355 * Logs a message with parameters at the {@link Level#FATAL FATAL} level. 1356 * 1357 * @param marker the marker data specific to this log statement. 1358 * @param message the message to log. 1359 * @param params parameters to the message. 1360 */ 1361 public void fatal(final Marker marker, final String message, final Object... params) { 1362 if (isEnabled(Level.FATAL, marker, message, params)) { 1363 final Message msg = messageFactory.newMessage(message, params); 1364 log(marker, FQCN, Level.FATAL, msg, msg.getThrowable()); 1365 } 1366 } 1367 1368 /** 1369 * Checks whether this Logger is enabled for the FATAL Level. 1370 * 1371 * @return boolean - {@code true} if this Logger is enabled for level 1372 * FATAL, {@code false} otherwise. 1373 */ 1374 public boolean isFatalEnabled() { 1375 return isEnabled(Level.FATAL, null, (Object) null, null); 1376 } 1377 1378 /** 1379 * Checks whether this Logger is enabled for the FATAL Level. 1380 * 1381 * @param marker The marker data. 1382 * @return boolean - {@code true} if this Logger is enabled for level 1383 * FATAL, {@code false} otherwise. 1384 */ 1385 public boolean isFatalEnabled(final Marker marker) { 1386 return isEnabled(Level.FATAL, marker, (Object) null, null); 1387 } 1388 1389 /** 1390 * Logs a message with the specific Marker at the FATAL level. 1391 * 1392 * @param msg the message string to be logged 1393 */ 1394 public void fatal(final Message msg) { 1395 if (isEnabled(Level.FATAL, null, msg, null)) { 1396 log(null, FQCN, Level.FATAL, msg, null); 1397 } 1398 } 1399 1400 /** 1401 * Logs a message with the specific Marker at the FATAL level. 1402 * 1403 * @param msg the message string to be logged 1404 * @param t A Throwable or null. 1405 */ 1406 public void fatal(final Message msg, final Throwable t) { 1407 if (isEnabled(Level.FATAL, null, msg, t)) { 1408 log(null, FQCN, Level.FATAL, msg, t); 1409 } 1410 } 1411 1412 /** 1413 * Logs a message with the specific Marker at the FATAL level. 1414 * 1415 * @param marker the marker data specific to this log statement 1416 * @param msg the message string to be logged 1417 */ 1418 public void fatal(final Marker marker, final Message msg) { 1419 if (isEnabled(Level.FATAL, marker, msg, null)) { 1420 log(marker, FQCN, Level.FATAL, msg, null); 1421 } 1422 } 1423 1424 /** 1425 * Logs a message with the specific Marker at the FATAL level. 1426 * 1427 * @param marker the marker data specific to this log statement 1428 * @param msg the message string to be logged 1429 * @param t A Throwable or null. 1430 */ 1431 public void fatal(final Marker marker, final Message msg, final Throwable t) { 1432 if (isEnabled(Level.FATAL, marker, msg, t)) { 1433 log(marker, FQCN, Level.FATAL, msg, t); 1434 } 1435 } 1436 1437 /** 1438 * Logs a message with location information. 1439 * 1440 * @param marker The Marker 1441 * @param fqcn The fully qualified class name of the <b>caller</b> 1442 * @param level The logging level 1443 * @param data The Message. 1444 * @param t A Throwable or null. 1445 */ 1446 protected abstract void log(Marker marker, String fqcn, Level level, Message data, Throwable t); 1447 1448 /* 1449 * Instead of one single method with Object... declared the following methods explicitly specify 1450 * parameters because they perform dramatically better than having the JVM convert them to an 1451 * array. 1452 */ 1453 1454 /** 1455 * Determine if logging is enabled. 1456 * @param level The logging Level to check. 1457 * @param marker A Marker or null. 1458 * @param data The message. 1459 * @return True if logging is enabled, false otherwise. 1460 */ 1461 protected abstract boolean isEnabled(Level level, Marker marker, String data); 1462 1463 /** 1464 * Determine if logging is enabled. 1465 * @param level The logging Level to check. 1466 * @param marker A Marker or null. 1467 * @param data The message. 1468 * @param t A Throwable. 1469 * @return True if logging is enabled, false otherwise. 1470 */ 1471 protected abstract boolean isEnabled(Level level, Marker marker, String data, Throwable t); 1472 1473 /** 1474 * Determine if logging is enabled. 1475 * @param level The logging Level to check. 1476 * @param marker A Marker or null. 1477 * @param data The message. 1478 * @param p1 The parameters. 1479 * @return True if logging is enabled, false otherwise. 1480 */ 1481 protected abstract boolean isEnabled(Level level, Marker marker, String data, Object... p1); 1482 1483 /** 1484 * Determine if logging is enabled. 1485 * @param level The logging Level to check. 1486 * @param marker A Marker or null. 1487 * @param data The message. 1488 * @param t A Throwable. 1489 * @return True if logging is enabled, false otherwise. 1490 */ 1491 protected abstract boolean isEnabled(Level level, Marker marker, Object data, Throwable t); 1492 1493 /** 1494 * Checks whether this Logger is enabled for the the given Level. 1495 * <p> 1496 * Note that passing in {@link Level#OFF OFF} always returns {@code true}. 1497 * </p> 1498 * @param level the level to check 1499 * @return boolean - {@code true} if this Logger is enabled for level, {@code false} otherwise. 1500 */ 1501 public boolean isEnabled(final Level level) { 1502 return isEnabled(level, null, (Object) null, null); 1503 } 1504 1505 /** 1506 * Determine if logging is enabled. 1507 * @param level The logging Level to check. 1508 * @param marker A Marker or null. 1509 * @param data The Message. 1510 * @param t A Throwable. 1511 * @return True if logging is enabled, false otherwise. 1512 */ 1513 protected abstract boolean isEnabled(Level level, Marker marker, Message data, Throwable t); 1514 1515 private Message entryMsg(final int count, final Object... params) { 1516 if (count == 0) { 1517 return messageFactory.newMessage(" entry"); 1518 } 1519 final StringBuilder sb = new StringBuilder(" entry parms("); 1520 int i = 0; 1521 for (final Object parm : params) { 1522 if (parm != null) { 1523 sb.append(parm.toString()); 1524 } else { 1525 sb.append("null"); 1526 } 1527 if (++i < params.length) { 1528 sb.append(", "); 1529 } 1530 } 1531 sb.append(")"); 1532 return messageFactory.newMessage(sb.toString()); 1533 } 1534 1535 private Message toExitMsg(final Object result) { 1536 if (result == null) { 1537 return messageFactory.newMessage(" exit"); 1538 } 1539 return messageFactory.newMessage(" exit with (" + result + ")"); 1540 } 1541 1542 /* (non-Javadoc) 1543 * @see org.apache.logging.log4j.Logger#getName() 1544 */ 1545 public String getName() { 1546 return name; 1547 } 1548 1549 /** 1550 * Returns a String representation of this instance in the form {@code "name"}. 1551 * @return A String describing this Logger instance. 1552 */ 1553 @Override 1554 public String toString() { 1555 return name; 1556 } 1557 1558 /** 1559 * Gets the message factory. 1560 * 1561 * @return the message factory. 1562 */ 1563 public MessageFactory getMessageFactory() { 1564 return messageFactory; 1565 } 1566 1567 }