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