1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache license, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the license for the specific language governing permissions and 15 * limitations under the license. 16 */ 17 package org.apache.logging.log4j; 18 19 import org.apache.logging.log4j.message.Message; 20 import org.apache.logging.log4j.message.MessageFactory; 21 import org.apache.logging.log4j.util.MessageSupplier; 22 import org.apache.logging.log4j.util.Supplier; 23 24 /** 25 * This is the central interface in the log4j package. Most logging operations, except configuration, are done through 26 * this interface. 27 * 28 * <p> 29 * The canonical way to obtain a Logger for a class is through {@link LogManager#getLogger()}. Typically, each class 30 * gets its own Logger named after its fully qualified class name (the default Logger name when obtained through the 31 * {@link LogManager#getLogger()} method). Thus, the simplest way to use this would be like so: 32 * </p> 33 * <pre> 34 * public class MyClass { 35 * private static final Logger LOGGER = LogManager.getLogger(); 36 * // ... 37 * } 38 * </pre> 39 * <p> 40 * For ease of filtering, searching, sorting, etc., it is generally a good idea to create Loggers for each class rather 41 * than sharing Loggers. Instead, {@link Marker Markers} should be used for shared, filterable identification. 42 * </p> 43 * <p> 44 * For service provider implementations, it is recommended to extend the 45 * {@link org.apache.logging.log4j.spi.AbstractLogger} class rather than implementing this interface directly. 46 * </p> 47 * 48 * Since 2.4, methods have been added to the {@code Logger} interface to support lambda expressions. 49 * The new methods allow client code to lazily log messages without explicitly checking if the requested log level is 50 * enabled. For example, previously one would write: 51 * 52 * <pre> 53 * // pre-Java 8 style optimization: explicitly check the log level 54 * // to make sure the expensiveOperation() method is only called if necessary 55 * if (logger.isTraceEnabled()) { 56 * logger.trace("Some long-running operation returned {}", expensiveOperation()); 57 * }</pre> 58 * <p> 59 * With Java 8, the same effect can be achieved with a lambda expression: 60 * 61 * <pre> 62 * // Java-8 style optimization: no need to explicitly check the log level: 63 * // the lambda expression is not evaluated if the TRACE level is not enabled 64 * logger.trace("Some long-running operation returned {}", () -> expensiveOperation()); 65 * </pre> 66 */ 67 public interface Logger { 68 69 /** 70 * Logs an exception or error that has been caught to a specific logging level. 71 * 72 * @param level The logging Level. 73 * @param t The Throwable. 74 */ 75 void catching(Level level, Throwable t); 76 77 /** 78 * Logs an exception or error that has been caught. Normally, one may wish to provide additional information with 79 * an exception while logging it; in these cases, one would not use this method. In other cases where simply 80 * logging the fact that an exception was swallowed somewhere (e.g., at the top of the stack trace in a 81 * {@code main()} method), this method is ideal for it. 82 * 83 * @param t The Throwable. 84 */ 85 void catching(Throwable t); 86 87 /** 88 * Logs a message with the specific Marker at the {@link Level#DEBUG DEBUG} level. 89 * 90 * @param marker the marker data specific to this log statement 91 * @param msg the message string to be logged 92 */ 93 void debug(Marker marker, Message msg); 94 95 /** 96 * Logs a message with the specific Marker at the {@link Level#DEBUG DEBUG} level. 97 * 98 * @param marker the marker data specific to this log statement 99 * @param msg the message string to be logged 100 * @param t A Throwable or null. 101 */ 102 void debug(Marker marker, Message msg, Throwable t); 103 104 /** 105 * Logs a message which is only to be constructed if the logging level is the {@link Level#DEBUG DEBUG} level with 106 * the specified Marker. The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the 107 * {@code Message}. 108 * 109 * @param marker the marker data specific to this log statement 110 * @param msgSupplier A function, which when called, produces the desired log message. 111 * @since 2.4 112 */ 113 void debug(Marker marker, MessageSupplier msgSupplier); 114 115 /** 116 * Logs a message (only to be constructed if the logging level is the {@link Level#DEBUG DEBUG} level) with the 117 * specified Marker and including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. The 118 * {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 119 * 120 * @param marker the marker data specific to this log statement 121 * @param msgSupplier A function, which when called, produces the desired log message. 122 * @param t A Throwable or null. 123 * @since 2.4 124 */ 125 void debug(Marker marker, MessageSupplier msgSupplier, Throwable t); 126 127 /** 128 * Logs a message object with the {@link Level#DEBUG DEBUG} level. 129 * 130 * @param marker the marker data specific to this log statement 131 * @param message the message object to log. 132 */ 133 void debug(Marker marker, Object message); 134 135 /** 136 * Logs a message at the {@link Level#DEBUG DEBUG} level including the stack trace of the {@link Throwable} 137 * <code>t</code> passed as parameter. 138 * 139 * @param marker the marker data specific to this log statement 140 * @param message the message to log. 141 * @param t the exception to log, including its stack trace. 142 */ 143 void debug(Marker marker, Object message, Throwable t); 144 145 /** 146 * Logs a message object with the {@link Level#DEBUG DEBUG} level. 147 * 148 * @param marker the marker data specific to this log statement 149 * @param message the message object to log. 150 */ 151 void debug(Marker marker, String message); 152 153 /** 154 * Logs a message with parameters at the {@link Level#DEBUG DEBUG} level. 155 * 156 * @param marker the marker data specific to this log statement 157 * @param message the message to log; the format depends on the message factory. 158 * @param params parameters to the message. 159 * @see #getMessageFactory() 160 */ 161 void debug(Marker marker, String message, Object... params); 162 163 /** 164 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#DEBUG 165 * DEBUG} level. 166 * 167 * @param marker the marker data specific to this log statement 168 * @param message the message to log; the format depends on the message factory. 169 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 170 * @since 2.4 171 */ 172 void debug(Marker marker, String message, Supplier<?>... paramSuppliers); 173 174 /** 175 * Logs a message at the {@link Level#DEBUG DEBUG} level including the stack trace of the {@link Throwable} 176 * <code>t</code> passed as parameter. 177 * 178 * @param marker the marker data specific to this log statement 179 * @param message the message to log. 180 * @param t the exception to log, including its stack trace. 181 */ 182 void debug(Marker marker, String message, Throwable t); 183 184 /** 185 * Logs a message which is only to be constructed if the logging level is the {@link Level#DEBUG DEBUG} level with 186 * the specified Marker. 187 * 188 * @param marker the marker data specific to this log statement 189 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 190 * message factory. 191 * @since 2.4 192 */ 193 void debug(Marker marker, Supplier<?> msgSupplier); 194 195 /** 196 * Logs a message (only to be constructed if the logging level is the {@link Level#DEBUG DEBUG} level) with the 197 * specified Marker and including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. 198 * 199 * @param marker the marker data specific to this log statement 200 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 201 * message factory. 202 * @param t A Throwable or null. 203 * @since 2.4 204 */ 205 void debug(Marker marker, Supplier<?> msgSupplier, Throwable t); 206 207 /** 208 * Logs a message with the specific Marker at the {@link Level#DEBUG DEBUG} level. 209 * 210 * @param msg the message string to be logged 211 */ 212 void debug(Message msg); 213 214 /** 215 * Logs a message with the specific Marker at the {@link Level#DEBUG DEBUG} level. 216 * 217 * @param msg the message string to be logged 218 * @param t A Throwable or null. 219 */ 220 void debug(Message msg, Throwable t); 221 222 /** 223 * Logs a message which is only to be constructed if the logging level is the {@link Level#DEBUG DEBUG} level. The 224 * {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 225 * 226 * @param msgSupplier A function, which when called, produces the desired log message. 227 * @since 2.4 228 */ 229 void debug(MessageSupplier msgSupplier); 230 231 /** 232 * Logs a message (only to be constructed if the logging level is the {@link Level#DEBUG DEBUG} level) including the 233 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. The {@code MessageSupplier} may or may 234 * not use the {@link MessageFactory} to construct the {@code Message}. 235 * 236 * @param msgSupplier A function, which when called, produces the desired log message. 237 * @param t the exception to log, including its stack trace. 238 * @since 2.4 239 */ 240 void debug(MessageSupplier msgSupplier, Throwable t); 241 242 /** 243 * Logs a message object with the {@link Level#DEBUG DEBUG} level. 244 * 245 * @param message the message object to log. 246 */ 247 void debug(Object message); 248 249 /** 250 * Logs a message at the {@link Level#DEBUG DEBUG} level including the stack trace of the {@link Throwable} 251 * <code>t</code> passed as parameter. 252 * 253 * @param message the message to log. 254 * @param t the exception to log, including its stack trace. 255 */ 256 void debug(Object message, Throwable t); 257 258 /** 259 * Logs a message object with the {@link Level#DEBUG DEBUG} level. 260 * 261 * @param message the message string to log. 262 */ 263 void debug(String message); 264 265 /** 266 * Logs a message with parameters at the {@link Level#DEBUG DEBUG} level. 267 * 268 * @param message the message to log; the format depends on the message factory. 269 * @param params parameters to the message. 270 * @see #getMessageFactory() 271 */ 272 void debug(String message, Object... params); 273 274 /** 275 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#DEBUG 276 * DEBUG} level. 277 * 278 * @param message the message to log; the format depends on the message factory. 279 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 280 * @since 2.4 281 */ 282 void debug(String message, Supplier<?>... paramSuppliers); 283 284 /** 285 * Logs a message at the {@link Level#DEBUG DEBUG} level including the stack trace of the {@link Throwable} 286 * <code>t</code> passed as parameter. 287 * 288 * @param message the message to log. 289 * @param t the exception to log, including its stack trace. 290 */ 291 void debug(String message, Throwable t); 292 293 /** 294 * Logs a message which is only to be constructed if the logging level is the {@link Level#DEBUG DEBUG} level. 295 * 296 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 297 * message factory. 298 * @since 2.4 299 */ 300 void debug(Supplier<?> msgSupplier); 301 302 /** 303 * Logs a message (only to be constructed if the logging level is the {@link Level#DEBUG DEBUG} level) including the 304 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 305 * 306 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 307 * message factory. 308 * @param t the exception to log, including its stack trace. 309 * @since 2.4 310 */ 311 void debug(Supplier<?> msgSupplier, Throwable t); 312 313 /** 314 * Logs entry to a method. Used when the method in question has no parameters or when the parameters should not be 315 * logged. 316 */ 317 void entry(); 318 319 /** 320 * Logs entry to a method along with its parameters. For example, 321 * <pre> 322 * public void doSomething(String foo, int bar) { 323 * LOGGER.entry(foo, bar); 324 * // do something 325 * } 326 * </pre> 327 * <p>The use of methods such as this are more effective when combined with aspect-oriented programming or other 328 * bytecode manipulation tools. It can be rather tedious (and messy) to use this type of method manually.</p> 329 * 330 * @param params The parameters to the method. 331 * TODO Use of varargs results in array creation which can be a substantial portion of no-op case. LogMF/LogSF 332 * provides several overrides to avoid vararg except in edge cases. (RG) LogMF and LogSF implement these in 333 * LogXF which calls logger.callAppenders. callAppenders is part of the implementation and cannot be used by 334 * the API. Adding more methods here and in AbstractLogger is sufficient. 335 */ 336 void entry(Object... params); 337 338 /** 339 * Logs a message with the specific Marker at the {@link Level#ERROR ERROR} level. 340 * 341 * @param marker the marker data specific to this log statement 342 * @param msg the message string to be logged 343 */ 344 void error(Marker marker, Message msg); 345 346 /** 347 * Logs a message with the specific Marker at the {@link Level#ERROR ERROR} level. 348 * 349 * @param marker the marker data specific to this log statement 350 * @param msg the message string to be logged 351 * @param t A Throwable or null. 352 */ 353 void error(Marker marker, Message msg, Throwable t); 354 355 /** 356 * Logs a message which is only to be constructed if the logging level is the {@link Level#ERROR ERROR} level with 357 * the specified Marker. 358 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 359 * 360 * @param marker the marker data specific to this log statement 361 * @param msgSupplier A function, which when called, produces the desired log message. 362 * @since 2.4 363 */ 364 void error(Marker marker, MessageSupplier msgSupplier); 365 366 /** 367 * Logs a message (only to be constructed if the logging level is the {@link Level#ERROR ERROR} level) with the 368 * specified Marker and including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. 369 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 370 * 371 * @param marker the marker data specific to this log statement 372 * @param msgSupplier A function, which when called, produces the desired log message. 373 * @param t A Throwable or null. 374 * @since 2.4 375 */ 376 void error(Marker marker, MessageSupplier msgSupplier, Throwable t); 377 378 /** 379 * Logs a message object with the {@link Level#ERROR ERROR} level. 380 * 381 * @param marker the marker data specific to this log statement. 382 * @param message the message object to log. 383 */ 384 void error(Marker marker, Object message); 385 386 /** 387 * Logs a message at the {@link Level#ERROR ERROR} level including the stack trace of the {@link Throwable} 388 * <code>t</code> passed as parameter. 389 * 390 * @param marker the marker data specific to this log statement. 391 * @param message the message object to log. 392 * @param t the exception to log, including its stack trace. 393 */ 394 void error(Marker marker, Object message, Throwable t); 395 396 /** 397 * Logs a message object with the {@link Level#ERROR ERROR} level. 398 * 399 * @param marker the marker data specific to this log statement. 400 * @param message the message object to log. 401 */ 402 void error(Marker marker, String message); 403 404 /** 405 * Logs a message with parameters at the {@link Level#ERROR ERROR} level. 406 * 407 * @param marker the marker data specific to this log statement. 408 * @param message the message to log; the format depends on the message factory. 409 * @param params parameters to the message. 410 * @see #getMessageFactory() 411 * 412 * TODO Likely to misinterpret existing log4j client code that intended to call info(Object,Throwable). Incurs 413 * array creation expense on every call. (RG) I assume you meant error, not info. It isn't possible to be 414 * misinterpreted as the previous method is for that signature. Methods should be added to avoid varargs for 415 * 1, 2 or 3 parameters. 416 */ 417 void error(Marker marker, String message, Object... params); 418 419 /** 420 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#ERROR 421 * ERROR} level. 422 * 423 * @param marker the marker data specific to this log statement 424 * @param message the message to log; the format depends on the message factory. 425 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 426 * @since 2.4 427 */ 428 void error(Marker marker, String message, Supplier<?>... paramSuppliers); 429 430 /** 431 * Logs a message at the {@link Level#ERROR ERROR} level including the stack trace of the {@link Throwable} 432 * <code>t</code> passed as parameter. 433 * 434 * @param marker the marker data specific to this log statement. 435 * @param message the message object to log. 436 * @param t the exception to log, including its stack trace. 437 */ 438 void error(Marker marker, String message, Throwable t); 439 440 /** 441 * Logs a message which is only to be constructed if the logging level is the {@link Level#ERROR ERROR} level with 442 * the specified Marker. 443 * 444 * @param marker the marker data specific to this log statement 445 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 446 * message factory. 447 * @since 2.4 448 */ 449 void error(Marker marker, Supplier<?> msgSupplier); 450 451 /** 452 * Logs a message (only to be constructed if the logging level is the {@link Level#ERROR ERROR} level) with the 453 * specified Marker and including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. 454 * 455 * @param marker the marker data specific to this log statement 456 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 457 * message factory. 458 * @param t A Throwable or null. 459 * @since 2.4 460 */ 461 void error(Marker marker, Supplier<?> msgSupplier, Throwable t); 462 463 /** 464 * Logs a message with the specific Marker at the {@link Level#ERROR ERROR} level. 465 * 466 * @param msg the message string to be logged 467 */ 468 void error(Message msg); 469 470 /** 471 * Logs a message with the specific Marker at the {@link Level#ERROR ERROR} level. 472 * 473 * @param msg the message string to be logged 474 * @param t A Throwable or null. 475 */ 476 void error(Message msg, Throwable t); 477 478 /** 479 * Logs a message which is only to be constructed if the logging level is the {@link Level#ERROR ERROR} level. 480 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 481 * 482 * @param msgSupplier A function, which when called, produces the desired log message. 483 * @since 2.4 484 */ 485 void error(MessageSupplier msgSupplier); 486 487 /** 488 * Logs a message (only to be constructed if the logging level is the {@link Level#ERROR ERROR} level) including the 489 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 490 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 491 * 492 * @param msgSupplier A function, which when called, produces the desired log message. 493 * @param t the exception to log, including its stack trace. 494 * @since 2.4 495 */ 496 void error(MessageSupplier msgSupplier, Throwable t); 497 498 /** 499 * Logs a message object with the {@link Level#ERROR ERROR} level. 500 * 501 * @param message the message object to log. 502 */ 503 void error(Object message); 504 505 /** 506 * Logs a message at the {@link Level#ERROR ERROR} level including the stack trace of the {@link Throwable} 507 * <code>t</code> passed as parameter. 508 * 509 * @param message the message object to log. 510 * @param t the exception to log, including its stack trace. 511 */ 512 void error(Object message, Throwable t); 513 514 /** 515 * Logs a message object with the {@link Level#ERROR ERROR} level. 516 * 517 * @param message the message string to log. 518 */ 519 void error(String message); 520 521 /** 522 * Logs a message with parameters at the {@link Level#ERROR ERROR} level. 523 * 524 * @param message the message to log; the format depends on the message factory. 525 * @param params parameters to the message. 526 * @see #getMessageFactory() 527 * 528 * TODO Likely to misinterpret existing log4j client code that intended to call info(Object,Throwable). Incurs 529 * array creation expense on every call. (RG) I assume you meant error, not info. It isn't possible to be 530 * misinterpreted as the previous method is for that signature. Methods should be added to avoid varargs for 531 * 1, 2 or 3 parameters. 532 */ 533 void error(String message, Object... params); 534 535 /** 536 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#ERROR 537 * ERROR} level. 538 * 539 * @param message the message to log; the format depends on the message factory. 540 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 541 * @since 2.4 542 */ 543 void error(String message, Supplier<?>... paramSuppliers); 544 545 /** 546 * Logs a message at the {@link Level#ERROR ERROR} level including the stack trace of the {@link Throwable} 547 * <code>t</code> passed as parameter. 548 * 549 * @param message the message object to log. 550 * @param t the exception to log, including its stack trace. 551 */ 552 void error(String message, Throwable t); 553 554 /** 555 * Logs a message which is only to be constructed if the logging level is the {@link Level#ERROR ERROR} level. 556 * 557 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 558 * message factory. 559 * @since 2.4 560 */ 561 void error(Supplier<?> msgSupplier); 562 563 /** 564 * Logs a message (only to be constructed if the logging level is the {@link Level#ERROR ERROR} level) including the 565 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 566 * 567 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 568 * message factory. 569 * @param t the exception to log, including its stack trace. 570 * @since 2.4 571 */ 572 void error(Supplier<?> msgSupplier, Throwable t); 573 574 /** 575 * Logs exit from a method. Used for methods that do not return anything. 576 */ 577 void exit(); 578 579 /** 580 * Logs exiting from a method with the result. This may be coded as: 581 * <pre> 582 * return LOGGER.exit(myResult); 583 * </pre> 584 * 585 * @param <R> The type of the parameter and object being returned. 586 * @param result The result being returned from the method call. 587 * @return the result. 588 */ 589 <R> R exit(R result); 590 591 /** 592 * Logs a message with the specific Marker at the {@link Level#FATAL FATAL} level. 593 * 594 * @param marker the marker data specific to this log statement 595 * @param msg the message string to be logged 596 */ 597 void fatal(Marker marker, Message msg); 598 599 /** 600 * Logs a message with the specific Marker at the {@link Level#FATAL FATAL} level. 601 * 602 * @param marker the marker data specific to this log statement 603 * @param msg the message string to be logged 604 * @param t A Throwable or null. 605 */ 606 void fatal(Marker marker, Message msg, Throwable t); 607 608 /** 609 * Logs a message which is only to be constructed if the logging level is the {@link Level#FATAL FATAL} level with 610 * the specified Marker. 611 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 612 * 613 * @param marker the marker data specific to this log statement 614 * @param msgSupplier A function, which when called, produces the desired log message. 615 * @since 2.4 616 */ 617 void fatal(Marker marker, MessageSupplier msgSupplier); 618 619 /** 620 * Logs a message (only to be constructed if the logging level is the {@link Level#FATAL FATAL} level) with the 621 * specified Marker and including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. 622 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 623 * 624 * @param marker the marker data specific to this log statement 625 * @param msgSupplier A function, which when called, produces the desired log message. 626 * @param t A Throwable or null. 627 * @since 2.4 628 */ 629 void fatal(Marker marker, MessageSupplier msgSupplier, Throwable t); 630 631 /** 632 * Logs a message object with the {@link Level#FATAL FATAL} level. 633 * 634 * @param marker The marker data specific to this log statement. 635 * @param message the message object to log. 636 */ 637 void fatal(Marker marker, Object message); 638 639 /** 640 * Logs a message at the {@link Level#FATAL FATAL} level including the stack trace of the {@link Throwable} 641 * <code>t</code> passed as parameter. 642 * 643 * @param marker The marker data specific to this log statement. 644 * @param message the message object to log. 645 * @param t the exception to log, including its stack trace. 646 */ 647 void fatal(Marker marker, Object message, Throwable t); 648 649 /** 650 * Logs a message object with the {@link Level#FATAL FATAL} level. 651 * 652 * @param marker The marker data specific to this log statement. 653 * @param message the message object to log. 654 */ 655 void fatal(Marker marker, String message); 656 657 /** 658 * Logs a message with parameters at the {@link Level#FATAL FATAL} level. 659 * 660 * @param marker The marker data specific to this log statement. 661 * @param message the message to log; the format depends on the message factory. 662 * @param params parameters to the message. 663 * @see #getMessageFactory() 664 * 665 * TODO Likely to misinterpret existing log4j client code that intended to call info(Object,Throwable). Incurs 666 * array creation expense on every call.(RG) I assume you meant fatal, not info. It isn't possible to be 667 * misinterpreted as the previous method is for that signature. Methods should be added to avoid varargs for 668 * 1, 2 or 3 parameters. 669 */ 670 void fatal(Marker marker, String message, Object... params); 671 672 /** 673 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#FATAL 674 * FATAL} level. 675 * 676 * @param marker the marker data specific to this log statement 677 * @param message the message to log; the format depends on the message factory. 678 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 679 * @since 2.4 680 */ 681 void fatal(Marker marker, String message, Supplier<?>... paramSuppliers); 682 683 /** 684 * Logs a message at the {@link Level#FATAL FATAL} level including the stack trace of the {@link Throwable} 685 * <code>t</code> passed as parameter. 686 * 687 * @param marker The marker data specific to this log statement. 688 * @param message the message object to log. 689 * @param t the exception to log, including its stack trace. 690 */ 691 void fatal(Marker marker, String message, Throwable t); 692 693 /** 694 * Logs a message which is only to be constructed if the logging level is the {@link Level#FATAL FATAL} level with 695 * the specified Marker. 696 * 697 * @param marker the marker data specific to this log statement 698 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 699 * message factory. 700 * @since 2.4 701 */ 702 void fatal(Marker marker, Supplier<?> msgSupplier); 703 704 /** 705 * Logs a message (only to be constructed if the logging level is the {@link Level#FATAL FATAL} level) with the 706 * specified Marker and including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. 707 * 708 * @param marker the marker data specific to this log statement 709 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 710 * message factory. 711 * @param t A Throwable or null. 712 * @since 2.4 713 */ 714 void fatal(Marker marker, Supplier<?> msgSupplier, Throwable t); 715 716 /** 717 * Logs a message with the specific Marker at the {@link Level#FATAL FATAL} level. 718 * 719 * @param msg the message string to be logged 720 */ 721 void fatal(Message msg); 722 723 /** 724 * Logs a message with the specific Marker at the {@link Level#FATAL FATAL} level. 725 * 726 * @param msg the message string to be logged 727 * @param t A Throwable or null. 728 */ 729 void fatal(Message msg, Throwable t); 730 731 /** 732 * Logs a message which is only to be constructed if the logging level is the {@link Level#FATAL FATAL} level. 733 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 734 * 735 * @param msgSupplier A function, which when called, produces the desired log message. 736 * @since 2.4 737 */ 738 void fatal(MessageSupplier msgSupplier); 739 740 /** 741 * Logs a message (only to be constructed if the logging level is the {@link Level#FATAL FATAL} level) including the 742 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 743 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 744 * 745 * @param msgSupplier A function, which when called, produces the desired log message. 746 * @param t the exception to log, including its stack trace. 747 * @since 2.4 748 */ 749 void fatal(MessageSupplier msgSupplier, Throwable t); 750 751 /** 752 * Logs a message object with the {@link Level#FATAL FATAL} level. 753 * 754 * @param message the message object to log. 755 */ 756 void fatal(Object message); 757 758 /** 759 * Logs a message at the {@link Level#FATAL FATAL} level including the stack trace of the {@link Throwable} 760 * <code>t</code> passed as parameter. 761 * 762 * @param message the message object to log. 763 * @param t the exception to log, including its stack trace. 764 */ 765 void fatal(Object message, Throwable t); 766 767 /** 768 * Logs a message object with the {@link Level#FATAL FATAL} level. 769 * 770 * @param message the message string to log. 771 */ 772 void fatal(String message); 773 774 /** 775 * Logs a message with parameters at the {@link Level#FATAL FATAL} level. 776 * 777 * @param message the message to log; the format depends on the message factory. 778 * @param params parameters to the message. 779 * @see #getMessageFactory() 780 * 781 * TODO Likely to misinterpret existing log4j client code that intended to call info(Object,Throwable). Incurs 782 * array creation expense on every call.(RG) I assume you meant fatal, not info. It isn't possible to be 783 * misinterpreted as the previous method is for that signature. Methods should be added to avoid varargs for 784 * 1, 2 or 3 parameters. 785 */ 786 void fatal(String message, Object... params); 787 788 /** 789 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#FATAL 790 * FATAL} level. 791 * 792 * @param message the message to log; the format depends on the message factory. 793 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 794 * @since 2.4 795 */ 796 void fatal(String message, Supplier<?>... paramSuppliers); 797 798 /** 799 * Logs a message at the {@link Level#FATAL FATAL} level including the stack trace of the {@link Throwable} 800 * <code>t</code> passed as parameter. 801 * 802 * @param message the message object to log. 803 * @param t the exception to log, including its stack trace. 804 */ 805 void fatal(String message, Throwable t); 806 807 /** 808 * Logs a message which is only to be constructed if the logging level is the {@link Level#FATAL FATAL} level. 809 * 810 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 811 * message factory. 812 * @since 2.4 813 */ 814 void fatal(Supplier<?> msgSupplier); 815 816 /** 817 * Logs a message (only to be constructed if the logging level is the {@link Level#FATAL FATAL} level) including the 818 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 819 * 820 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 821 * message factory. 822 * @param t the exception to log, including its stack trace. 823 * @since 2.4 824 */ 825 void fatal(Supplier<?> msgSupplier, Throwable t); 826 827 /** 828 * Gets the Level associated with the Logger. 829 * 830 * @return the Level associate with the Logger. 831 */ 832 Level getLevel(); 833 834 /** 835 * Gets the message factory used to convert message Objects and Strings into actual log Messages. 836 * 837 * @return the message factory. 838 */ 839 MessageFactory getMessageFactory(); 840 841 /** 842 * Gets the logger name. 843 * 844 * @return the logger name. 845 */ 846 String getName(); 847 848 /** 849 * Logs a message with the specific Marker at the {@link Level#INFO INFO} level. 850 * 851 * @param marker the marker data specific to this log statement 852 * @param msg the message string to be logged 853 */ 854 void info(Marker marker, Message msg); 855 856 /** 857 * Logs a message with the specific Marker at the {@link Level#INFO INFO} level. 858 * 859 * @param marker the marker data specific to this log statement 860 * @param msg the message string to be logged 861 * @param t A Throwable or null. 862 */ 863 void info(Marker marker, Message msg, Throwable t); 864 865 /** 866 * Logs a message which is only to be constructed if the logging level is the {@link Level#INFO INFO} level with 867 * the specified Marker. 868 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 869 * 870 * @param marker the marker data specific to this log statement 871 * @param msgSupplier A function, which when called, produces the desired log message. 872 * @since 2.4 873 */ 874 void info(Marker marker, MessageSupplier msgSupplier); 875 876 /** 877 * Logs a message (only to be constructed if the logging level is the {@link Level#INFO INFO} level) with the 878 * specified Marker and including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. 879 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 880 * 881 * @param marker the marker data specific to this log statement 882 * @param msgSupplier A function, which when called, produces the desired log message. 883 * @param t A Throwable or null. 884 * @since 2.4 885 */ 886 void info(Marker marker, MessageSupplier msgSupplier, Throwable t); 887 888 /** 889 * Logs a message object with the {@link Level#INFO INFO} level. 890 * 891 * @param marker the marker data specific to this log statement 892 * @param message the message object to log. 893 */ 894 void info(Marker marker, Object message); 895 896 /** 897 * Logs a message at the {@link Level#INFO INFO} level including the stack trace of the {@link Throwable} 898 * <code>t</code> passed as parameter. 899 * 900 * @param marker the marker data specific to this log statement 901 * @param message the message object to log. 902 * @param t the exception to log, including its stack trace. 903 */ 904 void info(Marker marker, Object message, Throwable t); 905 906 /** 907 * Logs a message object with the {@link Level#INFO INFO} level. 908 * 909 * @param marker the marker data specific to this log statement 910 * @param message the message object to log. 911 */ 912 void info(Marker marker, String message); 913 914 /** 915 * Logs a message with parameters at the {@link Level#INFO INFO} level. 916 * 917 * @param marker the marker data specific to this log statement 918 * @param message the message to log; the format depends on the message factory. 919 * @param params parameters to the message. 920 * @see #getMessageFactory() 921 * 922 * TODO Likely to misinterpret existing log4j client code that intended to call info(Object,Throwable). Incurs 923 * array creation expense on every call. (RG) It isn't possible to be misinterpreted as the previous method 924 * is for that signature. Methods should be added to avoid varargs for 1, 2 or 3 parameters. 925 */ 926 void info(Marker marker, String message, Object... params); 927 928 /** 929 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#INFO 930 * INFO} level. 931 * 932 * @param marker the marker data specific to this log statement 933 * @param message the message to log; the format depends on the message factory. 934 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 935 * @since 2.4 936 */ 937 void info(Marker marker, String message, Supplier<?>... paramSuppliers); 938 939 /** 940 * Logs a message at the {@link Level#INFO INFO} level including the stack trace of the {@link Throwable} 941 * <code>t</code> passed as parameter. 942 * 943 * @param marker the marker data specific to this log statement 944 * @param message the message object to log. 945 * @param t the exception to log, including its stack trace. 946 */ 947 void info(Marker marker, String message, Throwable t); 948 949 /** 950 * Logs a message which is only to be constructed if the logging level is the {@link Level#INFO INFO} level with the 951 * specified Marker. 952 * 953 * @param marker the marker data specific to this log statement 954 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 955 * message factory. 956 * @since 2.4 957 */ 958 void info(Marker marker, Supplier<?> msgSupplier); 959 960 /** 961 * Logs a message (only to be constructed if the logging level is the {@link Level#INFO INFO} level) with the 962 * specified Marker and including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. 963 * 964 * @param marker the marker data specific to this log statement 965 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 966 * message factory. 967 * @param t A Throwable or null. 968 * @since 2.4 969 */ 970 void info(Marker marker, Supplier<?> msgSupplier, Throwable t); 971 972 /** 973 * Logs a message with the specific Marker at the {@link Level#INFO INFO} level. 974 * 975 * @param msg the message string to be logged 976 */ 977 void info(Message msg); 978 979 /** 980 * Logs a message with the specific Marker at the {@link Level#INFO INFO} level. 981 * 982 * @param msg the message string to be logged 983 * @param t A Throwable or null. 984 */ 985 void info(Message msg, Throwable t); 986 987 /** 988 * Logs a message which is only to be constructed if the logging level is the {@link Level#INFO INFO} level. 989 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 990 * 991 * @param msgSupplier A function, which when called, produces the desired log message. 992 * @since 2.4 993 */ 994 void info(MessageSupplier msgSupplier); 995 996 /** 997 * Logs a message (only to be constructed if the logging level is the {@link Level#INFO INFO} level) including the 998 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 999 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1000 * 1001 * @param msgSupplier A function, which when called, produces the desired log message. 1002 * @param t the exception to log, including its stack trace. 1003 * @since 2.4 1004 */ 1005 void info(MessageSupplier msgSupplier, Throwable t); 1006 1007 /** 1008 * Logs a message object with the {@link Level#INFO INFO} level. 1009 * 1010 * @param message the message object to log. 1011 */ 1012 void info(Object message); 1013 1014 /** 1015 * Logs a message at the {@link Level#INFO INFO} level including the stack trace of the {@link Throwable} 1016 * <code>t</code> passed as parameter. 1017 * 1018 * @param message the message object to log. 1019 * @param t the exception to log, including its stack trace. 1020 */ 1021 void info(Object message, Throwable t); 1022 1023 /** 1024 * Logs a message object with the {@link Level#INFO INFO} level. 1025 * 1026 * @param message the message string to log. 1027 */ 1028 void info(String message); 1029 1030 /** 1031 * Logs a message with parameters at the {@link Level#INFO INFO} level. 1032 * 1033 * @param message the message to log; the format depends on the message factory. 1034 * @param params parameters to the message. 1035 * @see #getMessageFactory() 1036 * 1037 * TODO Likely to misinterpret existing log4j client code that intended to call info(Object,Throwable). Incurs 1038 * array creation expense on every call. (RG) It isn't possible to be misinterpreted as the previous method 1039 * is for that signature. Methods should be added to avoid varargs for 1, 2 or 3 parameters. 1040 */ 1041 void info(String message, Object... params); 1042 1043 /** 1044 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#INFO 1045 * INFO} level. 1046 * 1047 * @param message the message to log; the format depends on the message factory. 1048 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 1049 * @since 2.4 1050 */ 1051 void info(String message, Supplier<?>... paramSuppliers); 1052 1053 /** 1054 * Logs a message at the {@link Level#INFO INFO} level including the stack trace of the {@link Throwable} 1055 * <code>t</code> passed as parameter. 1056 * 1057 * @param message the message object to log. 1058 * @param t the exception to log, including its stack trace. 1059 */ 1060 void info(String message, Throwable t); 1061 1062 /** 1063 * Logs a message which is only to be constructed if the logging level is the {@link Level#INFO INFO} level. 1064 * 1065 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1066 * message factory. 1067 * @since 2.4 1068 */ 1069 void info(Supplier<?> msgSupplier); 1070 1071 /** 1072 * Logs a message (only to be constructed if the logging level is the {@link Level#INFO INFO} level) including the 1073 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1074 * 1075 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1076 * message factory. 1077 * @param t the exception to log, including its stack trace. 1078 * @since 2.4 1079 */ 1080 void info(Supplier<?> msgSupplier, Throwable t); 1081 1082 /** 1083 * Checks whether this Logger is enabled for the {@link Level#DEBUG DEBUG} Level. 1084 * 1085 * @return boolean - {@code true} if this Logger is enabled for level DEBUG, {@code false} otherwise. 1086 */ 1087 boolean isDebugEnabled(); 1088 1089 /** 1090 * Checks whether this Logger is enabled for the {@link Level#DEBUG DEBUG} Level. 1091 * 1092 * @param marker The marker data specific to this log statement. 1093 * @return boolean - {@code true} if this Logger is enabled for level DEBUG, {@code false} otherwise. 1094 */ 1095 boolean isDebugEnabled(Marker marker); 1096 1097 /** 1098 * Checks whether this Logger is enabled for the the given Level. 1099 * <p> 1100 * Note that passing in {@link Level#OFF OFF} always returns {@code true}. 1101 * </p> 1102 * 1103 * @param level the level to check 1104 * @return boolean - {@code true} if this Logger is enabled for level, {@code false} otherwise. 1105 */ 1106 boolean isEnabled(Level level); 1107 1108 /** 1109 * Checks whether this logger is enabled at the specified level and an optional Marker. 1110 * 1111 * @param level The Level to check. 1112 * @param marker The marker data specific to this log statement. 1113 * @return boolean - {@code true} if this Logger is enabled for level {@link Level#WARN WARN}, {@code false} 1114 * otherwise. 1115 */ 1116 boolean isEnabled(Level level, Marker marker); 1117 1118 /** 1119 * Checks whether this Logger is enabled for the {@link Level#ERROR ERROR} Level. 1120 * 1121 * @return boolean - {@code true} if this Logger is enabled for level {@link Level#ERROR ERROR}, {@code false} 1122 * otherwise. 1123 */ 1124 boolean isErrorEnabled(); 1125 1126 /** 1127 * Checks whether this Logger is enabled for the {@link Level#ERROR ERROR} Level. 1128 * 1129 * @param marker The marker data specific to this log statement. 1130 * @return boolean - {@code true} if this Logger is enabled for level {@link Level#ERROR ERROR}, {@code false} 1131 * otherwise. 1132 */ 1133 boolean isErrorEnabled(Marker marker); 1134 1135 /** 1136 * Checks whether this Logger is enabled for the {@link Level#FATAL FATAL} Level. 1137 * 1138 * @return boolean - {@code true} if this Logger is enabled for level {@link Level#FATAL FATAL}, {@code false} 1139 * otherwise. 1140 */ 1141 boolean isFatalEnabled(); 1142 1143 /** 1144 * Checks whether this Logger is enabled for the {@link Level#FATAL FATAL} Level. 1145 * 1146 * @param marker The marker data specific to this log statement. 1147 * @return boolean - {@code true} if this Logger is enabled for level {@link Level#FATAL FATAL}, {@code false} 1148 * otherwise. 1149 */ 1150 boolean isFatalEnabled(Marker marker); 1151 1152 /** 1153 * Checks whether this Logger is enabled for the {@link Level#INFO INFO} Level. 1154 * 1155 * @return boolean - {@code true} if this Logger is enabled for level INFO, {@code false} otherwise. 1156 */ 1157 boolean isInfoEnabled(); 1158 1159 /** 1160 * Checks whether this Logger is enabled for the {@link Level#INFO INFO} Level. 1161 * 1162 * @param marker The marker data specific to this log statement. 1163 * @return boolean - {@code true} if this Logger is enabled for level INFO, {@code false} otherwise. 1164 */ 1165 boolean isInfoEnabled(Marker marker); 1166 1167 /** 1168 * Checks whether this Logger is enabled for the {@link Level#TRACE TRACE} level. 1169 * 1170 * @return boolean - {@code true} if this Logger is enabled for level TRACE, {@code false} otherwise. 1171 */ 1172 boolean isTraceEnabled(); 1173 1174 /** 1175 * Checks whether this Logger is enabled for the {@link Level#TRACE TRACE} level. 1176 * 1177 * @param marker The marker data specific to this log statement. 1178 * @return boolean - {@code true} if this Logger is enabled for level TRACE, {@code false} otherwise. 1179 */ 1180 boolean isTraceEnabled(Marker marker); 1181 1182 /** 1183 * Checks whether this Logger is enabled for the {@link Level#WARN WARN} Level. 1184 * 1185 * @return boolean - {@code true} if this Logger is enabled for level {@link Level#WARN WARN}, {@code false} 1186 * otherwise. 1187 */ 1188 boolean isWarnEnabled(); 1189 1190 /** 1191 * Checks whether this Logger is enabled for the {@link Level#WARN WARN} Level. 1192 * 1193 * @param marker The marker data specific to this log statement. 1194 * @return boolean - {@code true} if this Logger is enabled for level {@link Level#WARN WARN}, {@code false} 1195 * otherwise. 1196 */ 1197 boolean isWarnEnabled(Marker marker); 1198 1199 /** 1200 * Logs a message with the specific Marker at the given level. 1201 * 1202 * @param level the logging level 1203 * @param marker the marker data specific to this log statement 1204 * @param msg the message string to be logged 1205 */ 1206 void log(Level level, Marker marker, Message msg); 1207 1208 /** 1209 * Logs a message with the specific Marker at the given level. 1210 * 1211 * @param level the logging level 1212 * @param marker the marker data specific to this log statement 1213 * @param msg the message string to be logged 1214 * @param t A Throwable or null. 1215 */ 1216 void log(Level level, Marker marker, Message msg, Throwable t); 1217 1218 /** 1219 * Logs a message which is only to be constructed if the logging level is the specified level with 1220 * the specified Marker. 1221 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1222 * 1223 * @param level the logging level 1224 * @param marker the marker data specific to this log statement 1225 * @param msgSupplier A function, which when called, produces the desired log message. 1226 * @since 2.4 1227 */ 1228 void log(Level level, Marker marker, MessageSupplier msgSupplier); 1229 1230 /** 1231 * Logs a message (only to be constructed if the logging level is the specified level) with the 1232 * specified Marker and including the stack log of the {@link Throwable} <code>t</code> passed as parameter. 1233 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1234 * 1235 * @param level the logging level 1236 * @param marker the marker data specific to this log statement 1237 * @param msgSupplier A function, which when called, produces the desired log message. 1238 * @param t A Throwable or null. 1239 * @since 2.4 1240 */ 1241 void log(Level level, Marker marker, MessageSupplier msgSupplier, Throwable t); 1242 1243 /** 1244 * Logs a message object with the given level. 1245 * 1246 * @param level the logging level 1247 * @param marker the marker data specific to this log statement 1248 * @param message the message object to log. 1249 */ 1250 void log(Level level, Marker marker, Object message); 1251 1252 /** 1253 * Logs a message at the given level including the stack trace of the {@link Throwable} <code>t</code> passed as 1254 * parameter. 1255 * 1256 * @param level the logging level 1257 * @param marker the marker data specific to this log statement 1258 * @param message the message to log. 1259 * @param t the exception to log, including its stack trace. 1260 */ 1261 void log(Level level, Marker marker, Object message, Throwable t); 1262 1263 1264 /** 1265 * Logs a message object with the given level. 1266 * 1267 * @param level the logging level 1268 * @param marker the marker data specific to this log statement 1269 * @param message the message object to log. 1270 */ 1271 void log(Level level, Marker marker, String message); 1272 1273 /** 1274 * Logs a message with parameters at the given level. 1275 * 1276 * @param level the logging level 1277 * @param marker the marker data specific to this log statement 1278 * @param message the message to log; the format depends on the message factory. 1279 * @param params parameters to the message. 1280 * @see #getMessageFactory() 1281 */ 1282 void log(Level level, Marker marker, String message, Object... params); 1283 1284 /** 1285 * Logs a message with parameters which are only to be constructed if the logging level is the specified level. 1286 * 1287 * @param level the logging level 1288 * @param marker the marker data specific to this log statement 1289 * @param message the message to log; the format depends on the message factory. 1290 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 1291 * @since 2.4 1292 */ 1293 void log(Level level, Marker marker, String message, Supplier<?>... paramSuppliers); 1294 1295 /** 1296 * Logs a message at the given level including the stack trace of the {@link Throwable} <code>t</code> passed as 1297 * parameter. 1298 * 1299 * @param level the logging level 1300 * @param marker the marker data specific to this log statement 1301 * @param message the message to log. 1302 * @param t the exception to log, including its stack trace. 1303 */ 1304 void log(Level level, Marker marker, String message, Throwable t); 1305 1306 /** 1307 * Logs a message (only to be constructed if the logging level is the specified level) with the specified Marker. 1308 * 1309 * @param level the logging level 1310 * @param marker the marker data specific to this log statement 1311 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1312 * message factory. 1313 * @since 2.4 1314 */ 1315 void log(Level level, Marker marker, Supplier<?> msgSupplier); 1316 1317 /** 1318 * Logs a message (only to be constructed if the logging level is the specified level) with the specified Marker and 1319 * including the stack log of the {@link Throwable} <code>t</code> passed as parameter. 1320 * 1321 * @param level the logging level 1322 * @param marker the marker data specific to this log statement 1323 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1324 * message factory. 1325 * @param t A Throwable or null. 1326 * @since 2.4 1327 */ 1328 void log(Level level, Marker marker, Supplier<?> msgSupplier, Throwable t); 1329 1330 /** 1331 * Logs a message with the specific Marker at the given level. 1332 * 1333 * @param level the logging level 1334 * @param msg the message string to be logged 1335 */ 1336 void log(Level level, Message msg); 1337 1338 /** 1339 * Logs a message with the specific Marker at the given level. 1340 * 1341 * @param level the logging level 1342 * @param msg the message string to be logged 1343 * @param t A Throwable or null. 1344 */ 1345 void log(Level level, Message msg, Throwable t); 1346 1347 /** 1348 * Logs a message which is only to be constructed if the logging level is the specified level. 1349 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1350 * 1351 * @param level the logging level 1352 * @param msgSupplier A function, which when called, produces the desired log message. 1353 * @since 2.4 1354 */ 1355 void log(Level level, MessageSupplier msgSupplier); 1356 1357 /** 1358 * Logs a message (only to be constructed if the logging level is the specified level) including the 1359 * stack log of the {@link Throwable} <code>t</code> passed as parameter. 1360 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1361 * 1362 * @param level the logging level 1363 * @param msgSupplier A function, which when called, produces the desired log message. 1364 * @param t the exception to log, including its stack log. 1365 * @since 2.4 1366 */ 1367 void log(Level level, MessageSupplier msgSupplier, Throwable t); 1368 1369 /** 1370 * Logs a message object with the given level. 1371 * 1372 * @param level the logging level 1373 * @param message the message object to log. 1374 */ 1375 void log(Level level, Object message); 1376 1377 /** 1378 * Logs a message at the given level including the stack trace of the {@link Throwable} <code>t</code> passed as 1379 * parameter. 1380 * 1381 * @param level the logging level 1382 * @param message the message to log. 1383 * @param t the exception to log, including its stack trace. 1384 */ 1385 void log(Level level, Object message, Throwable t); 1386 1387 /** 1388 * Logs a message object with the given level. 1389 * 1390 * @param level the logging level 1391 * @param message the message string to log. 1392 */ 1393 void log(Level level, String message); 1394 1395 /** 1396 * Logs a message with parameters at the given level. 1397 * 1398 * @param level the logging level 1399 * @param message the message to log; the format depends on the message factory. 1400 * @param params parameters to the message. 1401 * @see #getMessageFactory() 1402 */ 1403 void log(Level level, String message, Object... params); 1404 1405 /** 1406 * Logs a message with parameters which are only to be constructed if the logging level is the specified level. 1407 * 1408 * @param level the logging level 1409 * @param message the message to log; the format depends on the message factory. 1410 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 1411 * @since 2.4 1412 */ 1413 void log(Level level, String message, Supplier<?>... paramSuppliers); 1414 1415 /** 1416 * Logs a message at the given level including the stack trace of the {@link Throwable} <code>t</code> passed as 1417 * parameter. 1418 * 1419 * @param level the logging level 1420 * @param message the message to log. 1421 * @param t the exception to log, including its stack trace. 1422 */ 1423 void log(Level level, String message, Throwable t); 1424 1425 /** 1426 * Logs a message which is only to be constructed if the logging level is the specified level. 1427 * 1428 * @param level the logging level 1429 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1430 * message factory. 1431 * @since 2.4 1432 */ 1433 void log(Level level, Supplier<?> msgSupplier); 1434 1435 /** 1436 * Logs a message (only to be constructed if the logging level is the specified level) including the stack log of 1437 * the {@link Throwable} <code>t</code> passed as parameter. 1438 * 1439 * @param level the logging level 1440 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1441 * message factory. 1442 * @param t the exception to log, including its stack log. 1443 * @since 2.4 1444 */ 1445 void log(Level level, Supplier<?> msgSupplier, Throwable t); 1446 1447 /** 1448 * Logs a formatted message using the specified format string and arguments. 1449 * 1450 * @param level The logging Level. 1451 * @param marker the marker data specific to this log statement. 1452 * @param format The format String. 1453 * @param params Arguments specified by the format. 1454 */ 1455 void printf(Level level, Marker marker, String format, Object... params); 1456 1457 /** 1458 * Logs a formatted message using the specified format string and arguments. 1459 * 1460 * @param level The logging Level. 1461 * @param format The format String. 1462 * @param params Arguments specified by the format. 1463 */ 1464 void printf(Level level, String format, Object... params); 1465 1466 /** 1467 * Logs an exception or error to be thrown. This may be coded as: 1468 * <pre> 1469 * throw logger.throwing(Level.DEBUG, myException); 1470 * </pre> 1471 * 1472 * @param <T> the Throwable type. 1473 * @param level The logging Level. 1474 * @param t The Throwable. 1475 * @return the Throwable. 1476 */ 1477 <T extends Throwable> T throwing(Level level, T t); 1478 1479 /** 1480 * Logs an exception or error to be thrown. This may be coded as: 1481 * <pre> 1482 * throw logger.throwing(myException); 1483 * </pre> 1484 * 1485 * @param <T> the Throwable type. 1486 * @param t The Throwable. 1487 * @return the Throwable. 1488 */ 1489 <T extends Throwable> T throwing(T t); 1490 1491 /** 1492 * Logs a message with the specific Marker at the {@link Level#TRACE TRACE} level. 1493 * 1494 * @param marker the marker data specific to this log statement 1495 * @param msg the message string to be logged 1496 */ 1497 void trace(Marker marker, Message msg); 1498 1499 /** 1500 * Logs a message with the specific Marker at the {@link Level#TRACE TRACE} level. 1501 * 1502 * @param marker the marker data specific to this log statement 1503 * @param msg the message string to be logged 1504 * @param t A Throwable or null. 1505 */ 1506 void trace(Marker marker, Message msg, Throwable t); 1507 1508 /** 1509 * Logs a message which is only to be constructed if the logging level is the {@link Level#TRACE TRACE} level with 1510 * the specified Marker. 1511 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1512 * 1513 * @param marker the marker data specific to this log statement 1514 * @param msgSupplier A function, which when called, produces the desired log message. 1515 * @since 2.4 1516 */ 1517 void trace(Marker marker, MessageSupplier msgSupplier); 1518 1519 /** 1520 * Logs a message (only to be constructed if the logging level is the {@link Level#TRACE TRACE} level) with the 1521 * specified Marker and including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1522 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1523 * 1524 * @param marker the marker data specific to this log statement 1525 * @param msgSupplier A function, which when called, produces the desired log message. 1526 * @param t A Throwable or null. 1527 * @since 2.4 1528 */ 1529 void trace(Marker marker, MessageSupplier msgSupplier, Throwable t); 1530 1531 /** 1532 * Logs a message object with the {@link Level#TRACE TRACE} level. 1533 * 1534 * @param marker the marker data specific to this log statement 1535 * @param message the message object to log. 1536 */ 1537 void trace(Marker marker, Object message); 1538 1539 /** 1540 * Logs a message at the {@link Level#TRACE TRACE} level including the stack trace of the {@link Throwable} 1541 * <code>t</code> passed as parameter. 1542 * 1543 * @param marker the marker data specific to this log statement 1544 * @param message the message object to log. 1545 * @param t the exception to log, including its stack trace. 1546 * @see #debug(String) 1547 */ 1548 void trace(Marker marker, Object message, Throwable t); 1549 1550 /** 1551 * Logs a message object with the {@link Level#TRACE TRACE} level. 1552 * 1553 * @param marker the marker data specific to this log statement 1554 * @param message the message string to log. 1555 */ 1556 void trace(Marker marker, String message); 1557 1558 /** 1559 * Logs a message with parameters at the {@link Level#TRACE TRACE} level. 1560 * 1561 * @param marker the marker data specific to this log statement 1562 * @param message the message to log; the format depends on the message factory. 1563 * @param params parameters to the message. 1564 * @see #getMessageFactory() 1565 */ 1566 void trace(Marker marker, String message, Object... params); 1567 1568 /** 1569 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#TRACE 1570 * TRACE} level. 1571 * 1572 * @param marker the marker data specific to this log statement 1573 * @param message the message to log; the format depends on the message factory. 1574 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 1575 * @since 2.4 1576 */ 1577 void trace(Marker marker, String message, Supplier<?>... paramSuppliers); 1578 1579 /** 1580 * Logs a message at the {@link Level#TRACE TRACE} level including the stack trace of the {@link Throwable} 1581 * <code>t</code> passed as parameter. 1582 * 1583 * @param marker the marker data specific to this log statement 1584 * @param message the message object to log. 1585 * @param t the exception to log, including its stack trace. 1586 * @see #debug(String) 1587 */ 1588 void trace(Marker marker, String message, Throwable t); 1589 1590 /** 1591 * Logs a message which is only to be constructed if the logging level is the {@link Level#TRACE TRACE} level with 1592 * the specified Marker. 1593 * 1594 * @param marker the marker data specific to this log statement 1595 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1596 * message factory. 1597 * @since 2.4 1598 */ 1599 void trace(Marker marker, Supplier<?> msgSupplier); 1600 1601 /** 1602 * Logs a message (only to be constructed if the logging level is the {@link Level#TRACE TRACE} level) with the 1603 * specified Marker and including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1604 * 1605 * @param marker the marker data specific to this log statement 1606 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1607 * message factory. 1608 * @param t A Throwable or null. 1609 * @since 2.4 1610 */ 1611 void trace(Marker marker, Supplier<?> msgSupplier, Throwable t); 1612 1613 /** 1614 * Logs a message with the specific Marker at the {@link Level#TRACE TRACE} level. 1615 * 1616 * @param msg the message string to be logged 1617 */ 1618 void trace(Message msg); 1619 1620 /** 1621 * Logs a message with the specific Marker at the {@link Level#TRACE TRACE} level. 1622 * 1623 * @param msg the message string to be logged 1624 * @param t A Throwable or null. 1625 */ 1626 void trace(Message msg, Throwable t); 1627 1628 /** 1629 * Logs a message which is only to be constructed if the logging level is the {@link Level#TRACE TRACE} level. 1630 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1631 * 1632 * @param msgSupplier A function, which when called, produces the desired log message. 1633 * @since 2.4 1634 */ 1635 void trace(MessageSupplier msgSupplier); 1636 1637 /** 1638 * Logs a message (only to be constructed if the logging level is the {@link Level#TRACE TRACE} level) including the 1639 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1640 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1641 * 1642 * @param msgSupplier A function, which when called, produces the desired log message. 1643 * @param t the exception to log, including its stack trace. 1644 * @since 2.4 1645 */ 1646 void trace(MessageSupplier msgSupplier, Throwable t); 1647 1648 /** 1649 * Logs a message object with the {@link Level#TRACE TRACE} level. 1650 * 1651 * @param message the message object to log. 1652 */ 1653 void trace(Object message); 1654 1655 /** 1656 * Logs a message at the {@link Level#TRACE TRACE} level including the stack trace of the {@link Throwable} 1657 * <code>t</code> passed as parameter. 1658 * 1659 * @param message the message object to log. 1660 * @param t the exception to log, including its stack trace. 1661 * @see #debug(String) 1662 */ 1663 void trace(Object message, Throwable t); 1664 1665 /** 1666 * Logs a message object with the {@link Level#TRACE TRACE} level. 1667 * 1668 * @param message the message string to log. 1669 */ 1670 void trace(String message); 1671 1672 /** 1673 * Logs a message with parameters at the {@link Level#TRACE TRACE} level. 1674 * 1675 * @param message the message to log; the format depends on the message factory. 1676 * @param params parameters to the message. 1677 * @see #getMessageFactory() 1678 */ 1679 void trace(String message, Object... params); 1680 1681 /** 1682 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#TRACE 1683 * TRACE} level. 1684 * 1685 * @param message the message to log; the format depends on the message factory. 1686 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 1687 * @since 2.4 1688 */ 1689 void trace(String message, Supplier<?>... paramSuppliers); 1690 1691 /** 1692 * Logs a message at the {@link Level#TRACE TRACE} level including the stack trace of the {@link Throwable} 1693 * <code>t</code> passed as parameter. 1694 * 1695 * @param message the message object to log. 1696 * @param t the exception to log, including its stack trace. 1697 * @see #debug(String) 1698 */ 1699 void trace(String message, Throwable t); 1700 1701 /** 1702 * Logs a message which is only to be constructed if the logging level is the {@link Level#TRACE TRACE} level. 1703 * 1704 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1705 * message factory. 1706 * @since 2.4 1707 */ 1708 void trace(Supplier<?> msgSupplier); 1709 1710 /** 1711 * Logs a message (only to be constructed if the logging level is the {@link Level#TRACE TRACE} level) including the 1712 * stack trace of the {@link Throwable} <code>t</code> passed as parameter. 1713 * 1714 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1715 * message factory. 1716 * @param t the exception to log, including its stack trace. 1717 * @since 2.4 1718 */ 1719 void trace(Supplier<?> msgSupplier, Throwable t); 1720 1721 /** 1722 * Logs a message with the specific Marker at the {@link Level#WARN WARN} level. 1723 * 1724 * @param marker the marker data specific to this log statement 1725 * @param msg the message string to be logged 1726 */ 1727 void warn(Marker marker, Message msg); 1728 1729 /** 1730 * Logs a message with the specific Marker at the {@link Level#WARN WARN} level. 1731 * 1732 * @param marker the marker data specific to this log statement 1733 * @param msg the message string to be logged 1734 * @param t A Throwable or null. 1735 */ 1736 void warn(Marker marker, Message msg, Throwable t); 1737 1738 /** 1739 * Logs a message which is only to be constructed if the logging level is the {@link Level#WARN WARN} level with 1740 * the specified Marker. 1741 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1742 * 1743 * @param marker the marker data specific to this log statement 1744 * @param msgSupplier A function, which when called, produces the desired log message. 1745 * @since 2.4 1746 */ 1747 void warn(Marker marker, MessageSupplier msgSupplier); 1748 1749 /** 1750 * Logs a message (only to be constructed if the logging level is the {@link Level#WARN WARN} level) with the 1751 * specified Marker and including the stack warn of the {@link Throwable} <code>t</code> passed as parameter. 1752 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1753 * 1754 * @param marker the marker data specific to this log statement 1755 * @param msgSupplier A function, which when called, produces the desired log message. 1756 * @param t A Throwable or null. 1757 * @since 2.4 1758 */ 1759 void warn(Marker marker, MessageSupplier msgSupplier, Throwable t); 1760 1761 /** 1762 * Logs a message object with the {@link Level#WARN WARN} level. 1763 * 1764 * @param marker the marker data specific to this log statement 1765 * @param message the message object to log. 1766 */ 1767 void warn(Marker marker, Object message); 1768 1769 /** 1770 * Logs a message at the {@link Level#WARN WARN} level including the stack trace of the {@link Throwable} 1771 * <code>t</code> passed as parameter. 1772 * 1773 * @param marker the marker data specific to this log statement 1774 * @param message the message object to log. 1775 * @param t the exception to log, including its stack trace. 1776 */ 1777 void warn(Marker marker, Object message, Throwable t); 1778 1779 /** 1780 * Logs a message object with the {@link Level#WARN WARN} level. 1781 * 1782 * @param marker the marker data specific to this log statement 1783 * @param message the message object to log. 1784 */ 1785 void warn(Marker marker, String message); 1786 1787 /** 1788 * Logs a message with parameters at the {@link Level#WARN WARN} level. 1789 * 1790 * @param marker the marker data specific to this log statement. 1791 * @param message the message to log; the format depends on the message factory. 1792 * @param params parameters to the message. 1793 * @see #getMessageFactory() 1794 * 1795 * TODO Likely to misinterpret existing log4j client code that intended to call info(Object,Throwable). Incurs 1796 * array creation expense on every call. (RG) I assume you meant warn, not info. It isn't possible to be 1797 * misinterpreted as the previous method is for that signature.Methods should be added to avoid varargs for 1798 * 1, 2 or 3 parameters. 1799 */ 1800 void warn(Marker marker, String message, Object... params); 1801 1802 /** 1803 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#WARN 1804 * WARN} level. 1805 * 1806 * @param marker the marker data specific to this log statement 1807 * @param message the message to log; the format depends on the message factory. 1808 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 1809 * @since 2.4 1810 */ 1811 void warn(Marker marker, String message, Supplier<?>... paramSuppliers); 1812 1813 /** 1814 * Logs a message at the {@link Level#WARN WARN} level including the stack trace of the {@link Throwable} 1815 * <code>t</code> passed as parameter. 1816 * 1817 * @param marker the marker data specific to this log statement 1818 * @param message the message object to log. 1819 * @param t the exception to log, including its stack trace. 1820 */ 1821 void warn(Marker marker, String message, Throwable t); 1822 1823 /** 1824 * Logs a message which is only to be constructed if the logging level is the {@link Level#WARN WARN} level with the 1825 * specified Marker. 1826 * 1827 * @param marker the marker data specific to this log statement 1828 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1829 * message factory. 1830 * @since 2.4 1831 */ 1832 void warn(Marker marker, Supplier<?> msgSupplier); 1833 1834 /** 1835 * Logs a message (only to be constructed if the logging level is the {@link Level#WARN WARN} level) with the 1836 * specified Marker and including the stack warn of the {@link Throwable} <code>t</code> passed as parameter. 1837 * 1838 * @param marker the marker data specific to this log statement 1839 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1840 * message factory. 1841 * @param t A Throwable or null. 1842 * @since 2.4 1843 */ 1844 void warn(Marker marker, Supplier<?> msgSupplier, Throwable t); 1845 1846 /** 1847 * Logs a message with the specific Marker at the {@link Level#WARN WARN} level. 1848 * 1849 * @param msg the message string to be logged 1850 */ 1851 void warn(Message msg); 1852 1853 /** 1854 * Logs a message with the specific Marker at the {@link Level#WARN WARN} level. 1855 * 1856 * @param msg the message string to be logged 1857 * @param t A Throwable or null. 1858 */ 1859 void warn(Message msg, Throwable t); 1860 1861 /** 1862 * Logs a message which is only to be constructed if the logging level is the {@link Level#WARN WARN} level. 1863 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1864 * 1865 * @param msgSupplier A function, which when called, produces the desired log message. 1866 * @since 2.4 1867 */ 1868 void warn(MessageSupplier msgSupplier); 1869 1870 /** 1871 * Logs a message (only to be constructed if the logging level is the {@link Level#WARN WARN} level) including the 1872 * stack warn of the {@link Throwable} <code>t</code> passed as parameter. 1873 * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the {@code Message}. 1874 * 1875 * @param msgSupplier A function, which when called, produces the desired log message. 1876 * @param t the exception to log, including its stack warn. 1877 * @since 2.4 1878 */ 1879 void warn(MessageSupplier msgSupplier, Throwable t); 1880 1881 /** 1882 * Logs a message object with the {@link Level#WARN WARN} level. 1883 * 1884 * @param message the message object to log. 1885 */ 1886 void warn(Object message); 1887 1888 /** 1889 * Logs a message at the {@link Level#WARN WARN} level including the stack trace of the {@link Throwable} 1890 * <code>t</code> passed as parameter. 1891 * 1892 * @param message the message object to log. 1893 * @param t the exception to log, including its stack trace. 1894 */ 1895 void warn(Object message, Throwable t); 1896 1897 /** 1898 * Logs a message object with the {@link Level#WARN WARN} level. 1899 * 1900 * @param message the message string to log. 1901 */ 1902 void warn(String message); 1903 1904 /** 1905 * Logs a message with parameters at the {@link Level#WARN WARN} level. 1906 * 1907 * @param message the message to log; the format depends on the message factory. 1908 * @param params parameters to the message. 1909 * @see #getMessageFactory() 1910 * 1911 * TODO Likely to misinterpret existing log4j client code that intended to call info(Object,Throwable). Incurs 1912 * array creation expense on every call. (RG) I assume you meant warn, not info. It isn't possible to be 1913 * misinterpreted as the previous method is for that signature.Methods should be added to avoid varargs for 1914 * 1, 2 or 3 parameters. 1915 */ 1916 void warn(String message, Object... params); 1917 1918 /** 1919 * Logs a message with parameters which are only to be constructed if the logging level is the {@link Level#WARN 1920 * WARN} level. 1921 * 1922 * @param message the message to log; the format depends on the message factory. 1923 * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters. 1924 * @since 2.4 1925 */ 1926 void warn(String message, Supplier<?>... paramSuppliers); 1927 1928 /** 1929 * Logs a message at the {@link Level#WARN WARN} level including the stack trace of the {@link Throwable} 1930 * <code>t</code> passed as parameter. 1931 * 1932 * @param message the message object to log. 1933 * @param t the exception to log, including its stack trace. 1934 */ 1935 void warn(String message, Throwable t); 1936 1937 /** 1938 * Logs a message which is only to be constructed if the logging level is the {@link Level#WARN WARN} level. 1939 * 1940 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1941 * message factory. 1942 * @since 2.4 1943 */ 1944 void warn(Supplier<?> msgSupplier); 1945 1946 /** 1947 * Logs a message (only to be constructed if the logging level is the {@link Level#WARN WARN} level) including the 1948 * stack warn of the {@link Throwable} <code>t</code> passed as parameter. 1949 * 1950 * @param msgSupplier A function, which when called, produces the desired log message; the format depends on the 1951 * message factory. 1952 * @param t the exception to log, including its stack warn. 1953 * @since 2.4 1954 */ 1955 void warn(Supplier<?> msgSupplier, Throwable t); 1956 1957 }