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.log4j; 018 019import org.apache.log4j.spi.LoggingEvent; 020 021import java.text.DateFormat; 022import java.text.MessageFormat; 023import java.text.NumberFormat; 024import java.util.Date; 025import java.util.ResourceBundle; 026import java.util.Locale; 027 028 029/** 030 * This class provides parameterized logging services 031 * using the pattern syntax of java.text.MessageFormat. 032 * Message formatting is only performed when the 033 * request exceeds the threshold level of the logger. 034 * When the pattern only contains literal text and 035 * default conversion patterns (that is "{0}" and similar) 036 * a simple fast compatible formatter is used. 037 * If the pattern contains more complex conversion patterns, 038 * formatting will be delegated to java.text.MessageFormatter 039 * which can be substantially slower. 040 * 041 * @see org.apache.log4j.LogSF 042 * @since 1.2.16 043 * 044 */ 045public final class LogMF extends LogXF { 046 /** 047 * private constructor. 048 * 049 */ 050 private LogMF() { 051 } 052 053 /** 054 * Number format. 055 */ 056 private static NumberFormat numberFormat = null; 057 /** 058 * Locale at time of last number format request. 059 */ 060 private static Locale numberLocale = null; 061 /** 062 * Date format. 063 */ 064 private static DateFormat dateFormat = null; 065 /** 066 * Locale at time of last date format request. 067 */ 068 private static Locale dateLocale = null; 069 070 /** 071 * Format number. 072 * @param n number to format, may not be null. 073 * @return formatted value. 074 */ 075 private static synchronized String formatNumber(final Object n) { 076 Locale currentLocale = Locale.getDefault(); 077 if (currentLocale != numberLocale || numberFormat == null) { 078 numberLocale = currentLocale; 079 numberFormat = NumberFormat.getInstance(currentLocale); 080 } 081 return numberFormat.format(n); 082 } 083 084 085 /** 086 * Format date. 087 * @param d date, may not be null. 088 * @return formatted value. 089 */ 090 private static synchronized String formatDate(final Object d) { 091 Locale currentLocale = Locale.getDefault(); 092 if (currentLocale != dateLocale || dateFormat == null) { 093 dateLocale = currentLocale; 094 dateFormat = DateFormat.getDateTimeInstance( 095 DateFormat.SHORT, 096 DateFormat.SHORT, 097 currentLocale); 098 } 099 return dateFormat.format(d); 100 } 101 102 /** 103 * Format a single parameter like a "{0}" formatting specifier. 104 * 105 * @param arg0 parameter, may be null. 106 * @return string representation of arg0. 107 */ 108 private static String formatObject(final Object arg0) { 109 if (arg0 instanceof String) { 110 return arg0.toString(); 111 } else if (arg0 instanceof Double || 112 arg0 instanceof Float) { 113 return formatNumber(arg0); 114 } else if (arg0 instanceof Date) { 115 return formatDate(arg0); 116 } 117 return String.valueOf(arg0); 118 } 119 120 121 /** 122 * Determines if pattern contains only {n} format elements 123 * and not apostrophes. 124 * 125 * @param pattern pattern, may not be null. 126 * @return true if pattern only contains {n} format elements. 127 */ 128 private static boolean isSimple(final String pattern) { 129 if (pattern.indexOf('\'') != -1) { 130 return false; 131 } 132 for(int pos = pattern.indexOf('{'); 133 pos != -1; 134 pos = pattern.indexOf('{', pos + 1)) { 135 if (pos + 2 >= pattern.length() || 136 pattern.charAt(pos+2) != '}' || 137 pattern.charAt(pos+1) < '0' || 138 pattern.charAt(pos+1) > '9') { 139 return false; 140 } 141 } 142 return true; 143 144 } 145 146 /** 147 * Formats arguments using MessageFormat. 148 * @param pattern pattern, may be malformed or null. 149 * @param arguments arguments, may be null or mismatched. 150 * @return Message string or null 151 */ 152 private static String format(final String pattern, 153 final Object[] arguments) { 154 if (pattern == null) { 155 return null; 156 } else if(isSimple(pattern)) { 157 String formatted[] = new String[10]; 158 int prev = 0; 159 String retval = ""; 160 int pos = pattern.indexOf('{'); 161 while(pos >= 0) { 162 if(pos + 2 < pattern.length() && 163 pattern.charAt(pos+2) == '}' && 164 pattern.charAt(pos+1) >= '0' && 165 pattern.charAt(pos+1) <= '9') { 166 int index = pattern.charAt(pos+1) - '0'; 167 retval += pattern.substring(prev, pos); 168 if (formatted[index] == null) { 169 if (arguments == null || index >= arguments.length) { 170 formatted[index] = pattern.substring(pos, pos+3); 171 } else { 172 formatted[index] = formatObject(arguments[index]); 173 } 174 } 175 retval += formatted[index]; 176 prev = pos + 3; 177 pos = pattern.indexOf('{', prev); 178 } else { 179 pos = pattern.indexOf('{', pos + 1); 180 } 181 } 182 retval += pattern.substring(prev); 183 return retval; 184 } 185 try { 186 return MessageFormat.format(pattern, arguments); 187 } catch (IllegalArgumentException ex) { 188 return pattern; 189 } 190 } 191 192 /** 193 * Formats a single argument using MessageFormat. 194 * @param pattern pattern, may be malformed or null. 195 * @param arguments arguments, may be null or mismatched. 196 * @return Message string or null 197 */ 198 private static String format(final String pattern, 199 final Object arg0) { 200 if (pattern == null) { 201 return null; 202 } else if(isSimple(pattern)) { 203 String formatted = null; 204 int prev = 0; 205 String retval = ""; 206 int pos = pattern.indexOf('{'); 207 while(pos >= 0) { 208 if(pos + 2 < pattern.length() && 209 pattern.charAt(pos+2) == '}' && 210 pattern.charAt(pos+1) >= '0' && 211 pattern.charAt(pos+1) <= '9') { 212 int index = pattern.charAt(pos+1) - '0'; 213 retval += pattern.substring(prev, pos); 214 if (index != 0) { 215 retval += pattern.substring(pos, pos+3); 216 } else { 217 if (formatted == null) { 218 formatted = formatObject(arg0); 219 } 220 retval += formatted; 221 } 222 prev = pos + 3; 223 pos = pattern.indexOf('{', prev); 224 } else { 225 pos = pattern.indexOf('{', pos + 1); 226 } 227 } 228 retval += pattern.substring(prev); 229 return retval; 230 } 231 try { 232 return MessageFormat.format(pattern, new Object[] { arg0 }); 233 } catch (IllegalArgumentException ex) { 234 return pattern; 235 } 236 } 237 238 239 /** 240 * Formats arguments using MessageFormat using a pattern from 241 * a resource bundle. 242 * @param resourceBundleName name of resource bundle, may be null. 243 * @param key key for pattern in resource bundle, may be null. 244 * @param arguments arguments, may be null or mismatched. 245 * @return Message string or null 246 */ 247 private static String format( 248 final String resourceBundleName, 249 final String key, 250 final Object[] arguments) { 251 String pattern; 252 if (resourceBundleName != null) { 253 try { 254 ResourceBundle bundle = 255 ResourceBundle.getBundle(resourceBundleName); 256 pattern = bundle.getString(key); 257 } catch (Exception ex) { 258 pattern = key; 259 } 260 } else { 261 pattern = key; 262 } 263 return format(pattern, arguments); 264 } 265 266 267 /** 268 * Fully Qualified Class Name of this class. 269 */ 270 private static final String FQCN = LogMF.class.getName(); 271 272 /** 273 * Equivalent of Logger.forcedLog. 274 * 275 * @param logger logger, may not be null. 276 * @param level level, may not be null. 277 * @param msg message, may be null. 278 */ 279 private static void forcedLog(final Logger logger, 280 final Level level, 281 final String msg) { 282 logger.callAppenders(new LoggingEvent(FQCN, logger, level, msg, null)); 283 } 284 285 /** 286 * Equivalent of Logger.forcedLog. 287 * 288 * @param logger logger, may not be null. 289 * @param level level, may not be null. 290 * @param msg message, may be null. 291 * @param t throwable. 292 */ 293 private static void forcedLog(final Logger logger, 294 final Level level, 295 final String msg, 296 final Throwable t) { 297 logger.callAppenders(new LoggingEvent(FQCN, logger, level, msg, t)); 298 } 299 /** 300 * Log a parameterized message at trace level. 301 * @param logger logger, may not be null. 302 * @param pattern pattern, may be null. 303 * @param arguments an array of arguments to be 304 * formatted and substituted. 305 */ 306 public static void trace(final Logger logger, final String pattern, 307 final Object[] arguments) { 308 if (logger.isEnabledFor(TRACE)) { 309 forcedLog(logger, TRACE, format(pattern, arguments)); 310 } 311 } 312 313 /** 314 * Log a parameterized message at debug level. 315 * @param logger logger, may not be null. 316 * @param pattern pattern, may be null. 317 * @param arguments an array of arguments to be formatted and substituted. 318 */ 319 public static void debug(final Logger logger, final String pattern, 320 final Object[] arguments) { 321 if (logger.isDebugEnabled()) { 322 forcedLog(logger, Level.DEBUG, format(pattern, arguments)); 323 } 324 } 325 326 /** 327 * Log a parameterized message at info level. 328 * @param logger logger, may not be null. 329 * @param pattern pattern, may be null. 330 * @param arguments an array of arguments to be formatted and substituted. 331 */ 332 public static void info(final Logger logger, final String pattern, 333 final Object[] arguments) { 334 if (logger.isInfoEnabled()) { 335 forcedLog(logger, Level.INFO, format(pattern, arguments)); 336 } 337 } 338 339 /** 340 * Log a parameterized message at warn level. 341 * @param logger logger, may not be null. 342 * @param pattern pattern, may be null. 343 * @param arguments an array of arguments to be formatted and substituted. 344 */ 345 public static void warn(final Logger logger, final String pattern, 346 final Object[] arguments) { 347 if (logger.isEnabledFor(Level.WARN)) { 348 forcedLog(logger, Level.WARN, format(pattern, arguments)); 349 } 350 } 351 352 /** 353 * Log a parameterized message at error level. 354 * @param logger logger, may not be null. 355 * @param pattern pattern, may be null. 356 * @param arguments an array of arguments to be formatted and substituted. 357 */ 358 public static void error(final Logger logger, final String pattern, 359 final Object[] arguments) { 360 if (logger.isEnabledFor(Level.ERROR)) { 361 forcedLog(logger, Level.ERROR, format(pattern, arguments)); 362 } 363 } 364 365 /** 366 * Log a parameterized message at fatal level. 367 * @param logger logger, may not be null. 368 * @param pattern pattern, may be null. 369 * @param arguments an array of arguments to be formatted and substituted. 370 */ 371 public static void fatal(final Logger logger, final String pattern, 372 final Object[] arguments) { 373 if (logger.isEnabledFor(Level.FATAL)) { 374 forcedLog(logger, Level.FATAL, format(pattern, arguments)); 375 } 376 } 377 378 /** 379 * Log a parameterized message at trace level. 380 * @param logger logger, may not be null. 381 * @param t throwable, may be null. 382 * @param pattern pattern, may be null. 383 * @param arguments an array of arguments to be 384 * formatted and substituted. 385 */ 386 public static void trace(final Logger logger, 387 final Throwable t, 388 final String pattern, 389 final Object[] arguments) { 390 if (logger.isEnabledFor(TRACE)) { 391 forcedLog(logger, TRACE, format(pattern, arguments), t); 392 } 393 } 394 395 /** 396 * Log a parameterized message at debug level. 397 * @param logger logger, may not be null. 398 * @param t throwable, may be null. 399 * @param pattern pattern, may be null. 400 * @param arguments an array of arguments to be formatted and substituted. 401 */ 402 public static void debug(final Logger logger, 403 final Throwable t, 404 final String pattern, 405 final Object[] arguments) { 406 if (logger.isDebugEnabled()) { 407 forcedLog(logger, Level.DEBUG, format(pattern, arguments), t); 408 } 409 } 410 411 /** 412 * Log a parameterized message at info level. 413 * @param logger logger, may not be null. 414 * @param t throwable, may be null. 415 * @param pattern pattern, may be null. 416 * @param arguments an array of arguments to be formatted and substituted. 417 */ 418 public static void info(final Logger logger, 419 final Throwable t, 420 final String pattern, 421 final Object[] arguments) { 422 if (logger.isInfoEnabled()) { 423 forcedLog(logger, Level.INFO, format(pattern, arguments), t); 424 } 425 } 426 427 /** 428 * Log a parameterized message at warn level. 429 * @param logger logger, may not be null. 430 * @param t throwable, may be null. 431 * @param pattern pattern, may be null. 432 * @param arguments an array of arguments to be formatted and substituted. 433 */ 434 public static void warn(final Logger logger, 435 final Throwable t, 436 final String pattern, 437 final Object[] arguments) { 438 if (logger.isEnabledFor(Level.WARN)) { 439 forcedLog(logger, Level.WARN, format(pattern, arguments), t); 440 } 441 } 442 443 /** 444 * Log a parameterized message at error level. 445 * @param logger logger, may not be null. 446 * @param t throwable, may be null. 447 * @param pattern pattern, may be null. 448 * @param arguments an array of arguments to be formatted and substituted. 449 */ 450 public static void error(final Logger logger, 451 final Throwable t, 452 final String pattern, 453 final Object[] arguments) { 454 if (logger.isEnabledFor(Level.ERROR)) { 455 forcedLog(logger, Level.ERROR, format(pattern, arguments), t); 456 } 457 } 458 459 /** 460 * Log a parameterized message at fatal level. 461 * @param logger logger, may not be null. 462 * @param t throwable, may be null. 463 * @param pattern pattern, may be null. 464 * @param arguments an array of arguments to be formatted and substituted. 465 */ 466 public static void fatal(final Logger logger, 467 final Throwable t, 468 final String pattern, 469 final Object[] arguments) { 470 if (logger.isEnabledFor(Level.FATAL)) { 471 forcedLog(logger, Level.FATAL, format(pattern, arguments), t); 472 } 473 } 474 475 476 477 /** 478 * Log a parameterized message at trace level. 479 * @param logger logger, may not be null. 480 * @param pattern pattern, may be null. 481 * @param argument a value to be formatted and substituted. 482 */ 483 public static void trace(final Logger logger, final String pattern, 484 final boolean argument) { 485 if (logger.isEnabledFor(TRACE)) { 486 forcedLog(logger, TRACE, format(pattern, valueOf(argument))); 487 } 488 } 489 490 /** 491 * Log a parameterized message at trace level. 492 * @param logger logger, may not be null. 493 * @param pattern pattern, may be null. 494 * @param argument a value to be formatted and substituted. 495 */ 496 public static void trace(final Logger logger, final String pattern, 497 final char argument) { 498 if (logger.isEnabledFor(TRACE)) { 499 forcedLog(logger, TRACE, format(pattern, valueOf(argument))); 500 } 501 } 502 503 /** 504 * Log a parameterized message at trace level. 505 * @param logger logger, may not be null. 506 * @param pattern pattern, may be null. 507 * @param argument a value to be formatted and substituted. 508 */ 509 public static void trace(final Logger logger, final String pattern, 510 final byte argument) { 511 if (logger.isEnabledFor(TRACE)) { 512 forcedLog(logger, TRACE, format(pattern, valueOf(argument))); 513 } 514 } 515 516 /** 517 * Log a parameterized message at trace level. 518 * @param logger logger, may not be null. 519 * @param pattern pattern, may be null. 520 * @param argument a value to be formatted and substituted. 521 */ 522 public static void trace(final Logger logger, final String pattern, 523 final short argument) { 524 if (logger.isEnabledFor(TRACE)) { 525 forcedLog(logger, TRACE, format(pattern, valueOf(argument))); 526 } 527 } 528 529 /** 530 * Log a parameterized message at trace level. 531 * @param logger logger, may not be null. 532 * @param pattern pattern, may be null. 533 * @param argument a value to be formatted and substituted. 534 */ 535 public static void trace(final Logger logger, final String pattern, 536 final int argument) { 537 if (logger.isEnabledFor(TRACE)) { 538 forcedLog(logger, TRACE, format(pattern, valueOf(argument))); 539 } 540 } 541 542 /** 543 * Log a parameterized message at trace level. 544 * @param logger logger, may not be null. 545 * @param pattern pattern, may be null. 546 * @param argument a value to be formatted and substituted. 547 */ 548 public static void trace(final Logger logger, final String pattern, 549 final long argument) { 550 if (logger.isEnabledFor(TRACE)) { 551 forcedLog(logger, TRACE, format(pattern, valueOf(argument))); 552 } 553 } 554 555 /** 556 * Log a parameterized message at trace level. 557 * @param logger logger, may not be null. 558 * @param pattern pattern, may be null. 559 * @param argument a value to be formatted and substituted. 560 */ 561 public static void trace(final Logger logger, final String pattern, 562 final float argument) { 563 if (logger.isEnabledFor(TRACE)) { 564 forcedLog(logger, TRACE, format(pattern, valueOf(argument))); 565 } 566 } 567 568 /** 569 * Log a parameterized message at trace level. 570 * @param logger logger, may not be null. 571 * @param pattern pattern, may be null. 572 * @param argument a value to be formatted and substituted. 573 */ 574 public static void trace(final Logger logger, final String pattern, 575 final double argument) { 576 if (logger.isEnabledFor(TRACE)) { 577 forcedLog(logger, TRACE, format(pattern, valueOf(argument))); 578 } 579 } 580 581 /** 582 * Log a parameterized message at trace level. 583 * @param logger logger, may not be null. 584 * @param pattern pattern, may be null. 585 * @param argument a value to be formatted and substituted. 586 */ 587 public static void trace(final Logger logger, final String pattern, 588 final Object argument) { 589 if (logger.isEnabledFor(TRACE)) { 590 forcedLog(logger, TRACE, format(pattern, argument)); 591 } 592 } 593 594 /** 595 * Log a parameterized message at trace level. 596 * @param logger logger, may not be null. 597 * @param pattern pattern, may be null. 598 * @param arg0 a value to be formatted and substituted. 599 * @param arg1 a value to be formatted and substituted. 600 */ 601 public static void trace(final Logger logger, final String pattern, 602 final Object arg0, final Object arg1) { 603 if (logger.isEnabledFor(TRACE)) { 604 forcedLog(logger, TRACE, 605 format(pattern, toArray(arg0, arg1))); 606 } 607 } 608 609 /** 610 * Log a parameterized message at trace level. 611 * @param logger logger, may not be null. 612 * @param pattern pattern, may be null. 613 * @param arg0 a value to be formatted and substituted. 614 * @param arg1 a value to be formatted and substituted. 615 * @param arg2 a value to be formatted and substituted. 616 */ 617 public static void trace(final Logger logger, final String pattern, 618 final Object arg0, final Object arg1, final Object arg2) { 619 if (logger.isEnabledFor(TRACE)) { 620 forcedLog(logger, TRACE, 621 format(pattern, toArray(arg0, arg1, arg2))); 622 } 623 } 624 625 /** 626 * Log a parameterized message at trace level. 627 * @param logger logger, may not be null. 628 * @param pattern pattern, may be null. 629 * @param arg0 a value to be formatted and substituted. 630 * @param arg1 a value to be formatted and substituted. 631 * @param arg2 a value to be formatted and substituted. 632 * @param arg3 a value to be formatted and substituted. 633 */ 634 public static void trace(final Logger logger, final String pattern, 635 final Object arg0, final Object arg1, final Object arg2, 636 final Object arg3) { 637 if (logger.isEnabledFor(TRACE)) { 638 forcedLog(logger, TRACE, 639 format(pattern, toArray(arg0, arg1, arg2, arg3))); 640 } 641 } 642 643 /** 644 * Log a parameterized message at debug level. 645 * @param logger logger, may not be null. 646 * @param pattern pattern, may be null. 647 * @param argument a value to be formatted and substituted. 648 */ 649 public static void debug(final Logger logger, final String pattern, 650 final boolean argument) { 651 if (logger.isDebugEnabled()) { 652 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument))); 653 } 654 } 655 656 /** 657 * Log a parameterized message at debug level. 658 * @param logger logger, may not be null. 659 * @param pattern pattern, may be null. 660 * @param argument a value to be formatted and substituted. 661 */ 662 public static void debug(final Logger logger, final String pattern, 663 final char argument) { 664 if (logger.isDebugEnabled()) { 665 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument))); 666 } 667 } 668 669 /** 670 * Log a parameterized message at debug level. 671 * @param logger logger, may not be null. 672 * @param pattern pattern, may be null. 673 * @param argument a value to be formatted and substituted. 674 */ 675 public static void debug(final Logger logger, final String pattern, 676 final byte argument) { 677 if (logger.isDebugEnabled()) { 678 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument))); 679 } 680 } 681 682 /** 683 * Log a parameterized message at debug level. 684 * @param logger logger, may not be null. 685 * @param pattern pattern, may be null. 686 * @param argument a value to be formatted and substituted. 687 */ 688 public static void debug(final Logger logger, final String pattern, 689 final short argument) { 690 if (logger.isDebugEnabled()) { 691 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument))); 692 } 693 } 694 695 /** 696 * Log a parameterized message at debug level. 697 * @param logger logger, may not be null. 698 * @param pattern pattern, may be null. 699 * @param argument a value to be formatted and substituted. 700 */ 701 public static void debug(final Logger logger, final String pattern, 702 final int argument) { 703 if (logger.isDebugEnabled()) { 704 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument))); 705 } 706 } 707 708 /** 709 * Log a parameterized message at debug level. 710 * @param logger logger, may not be null. 711 * @param pattern pattern, may be null. 712 * @param argument a value to be formatted and substituted. 713 */ 714 public static void debug(final Logger logger, final String pattern, 715 final long argument) { 716 if (logger.isDebugEnabled()) { 717 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument))); 718 } 719 } 720 721 /** 722 * Log a parameterized message at debug level. 723 * @param logger logger, may not be null. 724 * @param pattern pattern, may be null. 725 * @param argument a value to be formatted and substituted. 726 */ 727 public static void debug(final Logger logger, final String pattern, 728 final float argument) { 729 if (logger.isDebugEnabled()) { 730 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument))); 731 } 732 } 733 734 /** 735 * Log a parameterized message at debug level. 736 * @param logger logger, may not be null. 737 * @param pattern pattern, may be null. 738 * @param argument a value to be formatted and substituted. 739 */ 740 public static void debug(final Logger logger, final String pattern, 741 final double argument) { 742 if (logger.isDebugEnabled()) { 743 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument))); 744 } 745 } 746 747 /** 748 * Log a parameterized message at debug level. 749 * @param logger logger, may not be null. 750 * @param pattern pattern, may be null. 751 * @param argument a value to be formatted and substituted. 752 */ 753 public static void debug(final Logger logger, final String pattern, 754 final Object argument) { 755 if (logger.isDebugEnabled()) { 756 forcedLog(logger, Level.DEBUG, format(pattern, argument)); 757 } 758 } 759 760 /** 761 * Log a parameterized message at debug level. 762 * @param logger logger, may not be null. 763 * @param pattern pattern, may be null. 764 * @param arg0 a value to be formatted and substituted. 765 * @param arg1 a value to be formatted and substituted. 766 */ 767 public static void debug(final Logger logger, final String pattern, 768 final Object arg0, final Object arg1) { 769 if (logger.isDebugEnabled()) { 770 forcedLog(logger, Level.DEBUG, 771 format(pattern, toArray(arg0, arg1))); 772 } 773 } 774 775 /** 776 * Log a parameterized message at debug level. 777 * @param logger logger, may not be null. 778 * @param pattern pattern, may be null. 779 * @param arg0 a value to be formatted and substituted. 780 * @param arg1 a value to be formatted and substituted. 781 * @param arg2 a value to be formatted and substituted. 782 */ 783 public static void debug(final Logger logger, final String pattern, 784 final Object arg0, final Object arg1, final Object arg2) { 785 if (logger.isDebugEnabled()) { 786 forcedLog(logger, Level.DEBUG, 787 format(pattern, toArray(arg0, arg1, arg2))); 788 } 789 } 790 791 /** 792 * Log a parameterized message at debug level. 793 * @param logger logger, may not be null. 794 * @param pattern pattern, may be null. 795 * @param arg0 a value to be formatted and substituted. 796 * @param arg1 a value to be formatted and substituted. 797 * @param arg2 a value to be formatted and substituted. 798 * @param arg3 a value to be formatted and substituted. 799 */ 800 public static void debug(final Logger logger, final String pattern, 801 final Object arg0, final Object arg1, final Object arg2, 802 final Object arg3) { 803 if (logger.isDebugEnabled()) { 804 forcedLog(logger, Level.DEBUG, 805 format(pattern, toArray(arg0, arg1, arg2, arg3))); 806 } 807 } 808 809 /** 810 * Log a parameterized message at info level. 811 * @param logger logger, may not be null. 812 * @param pattern pattern, may be null. 813 * @param argument a value to be formatted and substituted. 814 */ 815 public static void info(final Logger logger, final String pattern, 816 final boolean argument) { 817 if (logger.isInfoEnabled()) { 818 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument))); 819 } 820 } 821 822 /** 823 * Log a parameterized message at info level. 824 * @param logger logger, may not be null. 825 * @param pattern pattern, may be null. 826 * @param argument a value to be formatted and substituted. 827 */ 828 public static void info(final Logger logger, final String pattern, 829 final char argument) { 830 if (logger.isInfoEnabled()) { 831 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument))); 832 } 833 } 834 835 /** 836 * Log a parameterized message at info level. 837 * @param logger logger, may not be null. 838 * @param pattern pattern, may be null. 839 * @param argument a value to be formatted and substituted. 840 */ 841 public static void info(final Logger logger, final String pattern, 842 final byte argument) { 843 if (logger.isInfoEnabled()) { 844 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument))); 845 } 846 } 847 848 /** 849 * Log a parameterized message at info level. 850 * @param logger logger, may not be null. 851 * @param pattern pattern, may be null. 852 * @param argument a value to be formatted and substituted. 853 */ 854 public static void info(final Logger logger, final String pattern, 855 final short argument) { 856 if (logger.isInfoEnabled()) { 857 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument))); 858 } 859 } 860 861 /** 862 * Log a parameterized message at info level. 863 * @param logger logger, may not be null. 864 * @param pattern pattern, may be null. 865 * @param argument a value to be formatted and substituted. 866 */ 867 public static void info(final Logger logger, final String pattern, 868 final int argument) { 869 if (logger.isInfoEnabled()) { 870 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument))); 871 } 872 } 873 874 /** 875 * Log a parameterized message at info level. 876 * @param logger logger, may not be null. 877 * @param pattern pattern, may be null. 878 * @param argument a value to be formatted and substituted. 879 */ 880 public static void info(final Logger logger, final String pattern, 881 final long argument) { 882 if (logger.isInfoEnabled()) { 883 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument))); 884 } 885 } 886 887 /** 888 * Log a parameterized message at info level. 889 * @param logger logger, may not be null. 890 * @param pattern pattern, may be null. 891 * @param argument a value to be formatted and substituted. 892 */ 893 public static void info(final Logger logger, final String pattern, 894 final float argument) { 895 if (logger.isInfoEnabled()) { 896 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument))); 897 } 898 } 899 900 /** 901 * Log a parameterized message at info level. 902 * @param logger logger, may not be null. 903 * @param pattern pattern, may be null. 904 * @param argument a value to be formatted and substituted. 905 */ 906 public static void info(final Logger logger, final String pattern, 907 final double argument) { 908 if (logger.isInfoEnabled()) { 909 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument))); 910 } 911 } 912 913 /** 914 * Log a parameterized message at info level. 915 * @param logger logger, may not be null. 916 * @param pattern pattern, may be null. 917 * @param argument a value to be formatted and substituted. 918 */ 919 public static void info(final Logger logger, final String pattern, 920 final Object argument) { 921 if (logger.isInfoEnabled()) { 922 forcedLog(logger, Level.INFO, format(pattern, argument)); 923 } 924 } 925 926 /** 927 * Log a parameterized message at info level. 928 * @param logger logger, may not be null. 929 * @param pattern pattern, may be null. 930 * @param arg0 a value to be formatted and substituted. 931 * @param arg1 a value to be formatted and substituted. 932 */ 933 public static void info(final Logger logger, final String pattern, 934 final Object arg0, final Object arg1) { 935 if (logger.isInfoEnabled()) { 936 forcedLog(logger, Level.INFO, format(pattern, toArray(arg0, arg1))); 937 } 938 } 939 940 /** 941 * Log a parameterized message at info level. 942 * @param logger logger, may not be null. 943 * @param pattern pattern, may be null. 944 * @param arg0 a value to be formatted and substituted. 945 * @param arg1 a value to be formatted and substituted. 946 * @param arg2 a value to be formatted and substituted. 947 */ 948 public static void info(final Logger logger, final String pattern, 949 final Object arg0, final Object arg1, final Object arg2) { 950 if (logger.isInfoEnabled()) { 951 forcedLog(logger, Level.INFO, format(pattern, 952 toArray(arg0, arg1, arg2))); 953 } 954 } 955 956 /** 957 * Log a parameterized message at info level. 958 * @param logger logger, may not be null. 959 * @param pattern pattern, may be null. 960 * @param arg0 a value to be formatted and substituted. 961 * @param arg1 a value to be formatted and substituted. 962 * @param arg2 a value to be formatted and substituted. 963 * @param arg3 a value to be formatted and substituted. 964 */ 965 public static void info(final Logger logger, final String pattern, 966 final Object arg0, final Object arg1, final Object arg2, 967 final Object arg3) { 968 if (logger.isInfoEnabled()) { 969 forcedLog(logger, Level.INFO, format(pattern, 970 toArray(arg0, arg1, arg2, arg3))); 971 } 972 } 973 974 /** 975 * Log a parameterized message at warn level. 976 * @param logger logger, may not be null. 977 * @param pattern pattern, may be null. 978 * @param argument a value to be formatted and substituted. 979 */ 980 public static void warn(final Logger logger, final String pattern, 981 final boolean argument) { 982 if (logger.isEnabledFor(Level.WARN)) { 983 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument))); 984 } 985 } 986 987 /** 988 * Log a parameterized message at warn level. 989 * @param logger logger, may not be null. 990 * @param pattern pattern, may be null. 991 * @param argument a value to be formatted and substituted. 992 */ 993 public static void warn(final Logger logger, final String pattern, 994 final char argument) { 995 if (logger.isEnabledFor(Level.WARN)) { 996 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument))); 997 } 998 } 999 1000 /** 1001 * Log a parameterized message at warn level. 1002 * @param logger logger, may not be null. 1003 * @param pattern pattern, may be null. 1004 * @param argument a value to be formatted and substituted. 1005 */ 1006 public static void warn(final Logger logger, final String pattern, 1007 final byte argument) { 1008 if (logger.isEnabledFor(Level.WARN)) { 1009 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument))); 1010 } 1011 } 1012 1013 /** 1014 * Log a parameterized message at warn level. 1015 * @param logger logger, may not be null. 1016 * @param pattern pattern, may be null. 1017 * @param argument a value to be formatted and substituted. 1018 */ 1019 public static void warn(final Logger logger, final String pattern, 1020 final short argument) { 1021 if (logger.isEnabledFor(Level.WARN)) { 1022 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument))); 1023 } 1024 } 1025 1026 /** 1027 * Log a parameterized message at warn level. 1028 * @param logger logger, may not be null. 1029 * @param pattern pattern, may be null. 1030 * @param argument a value to be formatted and substituted. 1031 */ 1032 public static void warn(final Logger logger, final String pattern, 1033 final int argument) { 1034 if (logger.isEnabledFor(Level.WARN)) { 1035 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument))); 1036 } 1037 } 1038 1039 /** 1040 * Log a parameterized message at warn level. 1041 * @param logger logger, may not be null. 1042 * @param pattern pattern, may be null. 1043 * @param argument a value to be formatted and substituted. 1044 */ 1045 public static void warn(final Logger logger, final String pattern, 1046 final long argument) { 1047 if (logger.isEnabledFor(Level.WARN)) { 1048 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument))); 1049 } 1050 } 1051 1052 /** 1053 * Log a parameterized message at warn level. 1054 * @param logger logger, may not be null. 1055 * @param pattern pattern, may be null. 1056 * @param argument a value to be formatted and substituted. 1057 */ 1058 public static void warn(final Logger logger, final String pattern, 1059 final float argument) { 1060 if (logger.isEnabledFor(Level.WARN)) { 1061 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument))); 1062 } 1063 } 1064 1065 /** 1066 * Log a parameterized message at warn level. 1067 * @param logger logger, may not be null. 1068 * @param pattern pattern, may be null. 1069 * @param argument a value to be formatted and substituted. 1070 */ 1071 public static void warn(final Logger logger, final String pattern, 1072 final double argument) { 1073 if (logger.isEnabledFor(Level.WARN)) { 1074 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument))); 1075 } 1076 } 1077 1078 /** 1079 * Log a parameterized message at warn level. 1080 * @param logger logger, may not be null. 1081 * @param pattern pattern, may be null. 1082 * @param argument a value to be formatted and substituted. 1083 */ 1084 public static void warn(final Logger logger, final String pattern, 1085 final Object argument) { 1086 if (logger.isEnabledFor(Level.WARN)) { 1087 forcedLog(logger, Level.WARN, format(pattern, argument)); 1088 } 1089 } 1090 1091 /** 1092 * Log a parameterized message at warn level. 1093 * @param logger logger, may not be null. 1094 * @param pattern pattern, may be null. 1095 * @param arg0 a value to be formatted and substituted. 1096 * @param arg1 a value to be formatted and substituted. 1097 */ 1098 public static void warn(final Logger logger, final String pattern, 1099 final Object arg0, final Object arg1) { 1100 if (logger.isEnabledFor(Level.WARN)) { 1101 forcedLog(logger, Level.WARN, 1102 format(pattern, toArray(arg0, arg1))); 1103 } 1104 } 1105 1106 /** 1107 * Log a parameterized message at warn level. 1108 * @param logger logger, may not be null. 1109 * @param pattern pattern, may be null. 1110 * @param arg0 a value to be formatted and substituted. 1111 * @param arg1 a value to be formatted and substituted. 1112 * @param arg2 a value to be formatted and substituted. 1113 */ 1114 public static void warn(final Logger logger, final String pattern, 1115 final Object arg0, final Object arg1, final Object arg2) { 1116 if (logger.isEnabledFor(Level.WARN)) { 1117 forcedLog(logger, Level.WARN, 1118 format(pattern, toArray(arg0, arg1, arg2))); 1119 } 1120 } 1121 1122 /** 1123 * Log a parameterized message at warn level. 1124 * @param logger logger, may not be null. 1125 * @param pattern pattern, may be null. 1126 * @param arg0 a value to be formatted and substituted. 1127 * @param arg1 a value to be formatted and substituted. 1128 * @param arg2 a value to be formatted and substituted. 1129 * @param arg3 a value to be formatted and substituted. 1130 */ 1131 public static void warn(final Logger logger, final String pattern, 1132 final Object arg0, final Object arg1, final Object arg2, 1133 final Object arg3) { 1134 if (logger.isEnabledFor(Level.WARN)) { 1135 forcedLog(logger, Level.WARN, format(pattern, 1136 toArray(arg0, arg1, arg2, arg3))); 1137 } 1138 } 1139 1140 /** 1141 * Log a parameterized message at specified level. 1142 * @param logger logger, may not be null. 1143 * @param level level, may not be null. 1144 * @param pattern pattern, may be null. 1145 * @param parameters parameters to the log message. 1146 */ 1147 public static void log(final Logger logger, 1148 final Level level, 1149 final String pattern, 1150 final Object[] parameters) { 1151 if (logger.isEnabledFor(level)) { 1152 forcedLog(logger, level, 1153 format(pattern, parameters)); 1154 } 1155 } 1156 1157 /** 1158 * Log a parameterized message at specified level. 1159 * @param logger logger, may not be null. 1160 * @param level level, may not be null. 1161 * @param t throwable, may be null. 1162 * @param pattern pattern, may be null. 1163 * @param parameters parameters to the log message. 1164 */ 1165 public static void log(final Logger logger, 1166 final Level level, 1167 final Throwable t, 1168 final String pattern, 1169 final Object[] parameters) { 1170 if (logger.isEnabledFor(level)) { 1171 forcedLog(logger, level, 1172 format(pattern, parameters), t); 1173 } 1174 } 1175 1176 /** 1177 * Log a parameterized message at specified level. 1178 * @param logger logger, may not be null. 1179 * @param level level, may not be null. 1180 * @param pattern pattern, may be null. 1181 * @param param1 parameter to the log message. 1182 */ 1183 public static void log(final Logger logger, 1184 final Level level, 1185 final String pattern, 1186 final Object param1) { 1187 if (logger.isEnabledFor(level)) { 1188 forcedLog(logger, level, 1189 format(pattern, toArray(param1))); 1190 } 1191 } 1192 1193 /** 1194 * Log a parameterized message at specified level. 1195 * @param logger logger, may not be null. 1196 * @param level level, may not be null. 1197 * @param pattern pattern, may be null. 1198 * @param param1 parameter to the log message. 1199 */ 1200 public static void log(final Logger logger, 1201 final Level level, 1202 final String pattern, 1203 final boolean param1) { 1204 if (logger.isEnabledFor(level)) { 1205 forcedLog(logger, level, 1206 format(pattern, toArray(valueOf(param1)))); 1207 } 1208 } 1209 1210 1211 /** 1212 * Log a parameterized message at specified level. 1213 * @param logger logger, may not be null. 1214 * @param level level, may not be null. 1215 * @param pattern pattern, may be null. 1216 * @param param1 parameter to the log message. 1217 */ 1218 public static void log(final Logger logger, 1219 final Level level, 1220 final String pattern, 1221 final byte param1) { 1222 if (logger.isEnabledFor(level)) { 1223 forcedLog(logger, level, 1224 format(pattern, toArray(valueOf(param1)))); 1225 } 1226 } 1227 1228 1229 /** 1230 * Log a parameterized message at specified level. 1231 * @param logger logger, may not be null. 1232 * @param level level, may not be null. 1233 * @param pattern pattern, may be null. 1234 * @param param1 parameter to the log message. 1235 */ 1236 public static void log(final Logger logger, 1237 final Level level, 1238 final String pattern, 1239 final char param1) { 1240 if (logger.isEnabledFor(level)) { 1241 forcedLog(logger, level, 1242 format(pattern, toArray(valueOf(param1)))); 1243 } 1244 } 1245 1246 /** 1247 * Log a parameterized message at specified level. 1248 * @param logger logger, may not be null. 1249 * @param level level, may not be null. 1250 * @param pattern pattern, may be null. 1251 * @param param1 parameter to the log message. 1252 */ 1253 public static void log(final Logger logger, 1254 final Level level, 1255 final String pattern, 1256 final short param1) { 1257 if (logger.isEnabledFor(level)) { 1258 forcedLog(logger, level, 1259 format(pattern, toArray(valueOf(param1)))); 1260 } 1261 } 1262 1263 /** 1264 * Log a parameterized message at specified level. 1265 * @param logger logger, may not be null. 1266 * @param level level, may not be null. 1267 * @param pattern pattern, may be null. 1268 * @param param1 parameter to the log message. 1269 */ 1270 public static void log(final Logger logger, 1271 final Level level, 1272 final String pattern, 1273 final int param1) { 1274 if (logger.isEnabledFor(level)) { 1275 forcedLog(logger, level, 1276 format(pattern, toArray(valueOf(param1)))); 1277 } 1278 } 1279 1280 1281 /** 1282 * Log a parameterized message at specified level. 1283 * @param logger logger, may not be null. 1284 * @param level level, may not be null. 1285 * @param pattern pattern, may be null. 1286 * @param param1 parameter to the log message. 1287 */ 1288 public static void log(final Logger logger, 1289 final Level level, 1290 final String pattern, 1291 final long param1) { 1292 if (logger.isEnabledFor(level)) { 1293 forcedLog(logger, level, 1294 format(pattern, toArray(valueOf(param1)))); 1295 } 1296 } 1297 1298 1299 /** 1300 * Log a parameterized message at specified level. 1301 * @param logger logger, may not be null. 1302 * @param level level, may not be null. 1303 * @param pattern pattern, may be null. 1304 * @param param1 parameter to the log message. 1305 */ 1306 public static void log(final Logger logger, 1307 final Level level, 1308 final String pattern, 1309 final float param1) { 1310 if (logger.isEnabledFor(level)) { 1311 forcedLog(logger, level, 1312 format(pattern, toArray(valueOf(param1)))); 1313 } 1314 } 1315 1316 1317 /** 1318 * Log a parameterized message at specified level. 1319 * @param logger logger, may not be null. 1320 * @param level level, may not be null. 1321 * @param pattern pattern, may be null. 1322 * @param param1 parameter to the log message. 1323 */ 1324 public static void log(final Logger logger, 1325 final Level level, 1326 final String pattern, 1327 final double param1) { 1328 if (logger.isEnabledFor(level)) { 1329 forcedLog(logger, level, 1330 format(pattern, toArray(valueOf(param1)))); 1331 } 1332 } 1333 1334 1335 /** 1336 * Log a parameterized message at specified level. 1337 * @param logger logger, may not be null. 1338 * @param level level, may not be null. 1339 * @param pattern pattern, may be null. 1340 * @param arg0 a value to be formatted and substituted. 1341 * @param arg1 a value to be formatted and substituted. 1342 */ 1343 public static void log(final Logger logger, 1344 final Level level, 1345 final String pattern, 1346 final Object arg0, final Object arg1) { 1347 if (logger.isEnabledFor(level)) { 1348 forcedLog(logger, level, 1349 format(pattern, toArray(arg0, arg1))); 1350 } 1351 } 1352 1353 /** 1354 * Log a parameterized message at specifed level. 1355 * @param logger logger, may not be null. 1356 * @param level level, may not be null. 1357 * @param pattern pattern, may be null. 1358 * @param arg0 a value to be formatted and substituted. 1359 * @param arg1 a value to be formatted and substituted. 1360 * @param arg2 a value to be formatted and substituted. 1361 */ 1362 public static void log(final Logger logger, 1363 final Level level, 1364 final String pattern, 1365 final Object arg0, final Object arg1, final Object arg2) { 1366 if (logger.isEnabledFor(level)) { 1367 forcedLog(logger, level, 1368 format(pattern, toArray(arg0, arg1, arg2))); 1369 } 1370 } 1371 1372 /** 1373 * Log a parameterized message at specified level. 1374 * @param logger logger, may not be null. 1375 * @param pattern pattern, may be null. 1376 * @param level level, may not be null. 1377 * @param arg0 a value to be formatted and substituted. 1378 * @param arg1 a value to be formatted and substituted. 1379 * @param arg2 a value to be formatted and substituted. 1380 * @param arg3 a value to be formatted and substituted. 1381 */ 1382 public static void log(final Logger logger, 1383 final Level level, 1384 final String pattern, 1385 final Object arg0, final Object arg1, final Object arg2, 1386 final Object arg3) { 1387 if (logger.isEnabledFor(level)) { 1388 forcedLog(logger, level, format(pattern, 1389 toArray(arg0, arg1, arg2, arg3))); 1390 } 1391 } 1392 1393 1394 /** 1395 * Log a parameterized message using a pattern from a resource bundle. 1396 * @param logger logger, may not be null. 1397 * @param level level, may not be null. 1398 * @param bundleName resource bundle name, may be null. 1399 * @param key key, may be null. 1400 * @param parameters parameters to the log message. 1401 */ 1402 public static void logrb(final Logger logger, 1403 final Level level, 1404 final String bundleName, 1405 final String key, 1406 final Object[] parameters) { 1407 if (logger.isEnabledFor(level)) { 1408 forcedLog(logger, level, 1409 format(bundleName, key, parameters)); 1410 } 1411 } 1412 1413 /** 1414 * Log a parameterized message using a pattern from a resource bundle. 1415 * @param logger logger, may not be null. 1416 * @param level level, may not be null. 1417 * @param t throwable, may be null. 1418 * @param bundleName resource bundle name, may be null. 1419 * @param key key, may be null. 1420 * @param parameters parameters to the log message. 1421 */ 1422 public static void logrb(final Logger logger, 1423 final Level level, 1424 final Throwable t, 1425 final String bundleName, 1426 final String key, 1427 final Object[] parameters) { 1428 if (logger.isEnabledFor(level)) { 1429 forcedLog(logger, level, 1430 format(bundleName, key, parameters), t); 1431 } 1432 } 1433 1434 /** 1435 * Log a parameterized message using a pattern from a resource bundle. 1436 * @param logger logger, may not be null. 1437 * @param level level, may not be null. 1438 * @param bundleName resource bundle name, may be null. 1439 * @param key key, may be null. 1440 * @param param1 Parameter to the log message. 1441 */ 1442 public static void logrb(final Logger logger, 1443 final Level level, 1444 final String bundleName, 1445 final String key, 1446 final Object param1) { 1447 if (logger.isEnabledFor(level)) { 1448 forcedLog(logger, level, 1449 format(bundleName, key, toArray(param1))); 1450 } 1451 } 1452 1453 /** 1454 * Log a parameterized message using a pattern from a resource bundle. 1455 * @param logger logger, may not be null. 1456 * @param level level, may not be null. 1457 * @param bundleName resource bundle name, may be null. 1458 * @param key key, may be null. 1459 * @param param1 Parameter to the log message. 1460 */ 1461 public static void logrb(final Logger logger, 1462 final Level level, 1463 final String bundleName, 1464 final String key, 1465 final boolean param1) { 1466 if (logger.isEnabledFor(level)) { 1467 forcedLog(logger, level, 1468 format(bundleName, key, toArray(valueOf(param1)))); 1469 } 1470 } 1471 1472 /** 1473 * Log a parameterized message using a pattern from a resource bundle. 1474 * @param logger logger, may not be null. 1475 * @param level level, may not be null. 1476 * @param bundleName resource bundle name, may be null. 1477 * @param key key, may be null. 1478 * @param param1 Parameter to the log message. 1479 */ 1480 public static void logrb(final Logger logger, 1481 final Level level, 1482 final String bundleName, 1483 final String key, 1484 final char param1) { 1485 if (logger.isEnabledFor(level)) { 1486 forcedLog(logger, level, 1487 format(bundleName, key, toArray(valueOf(param1)))); 1488 } 1489 } 1490 1491 /** 1492 * Log a parameterized message using a pattern from a resource bundle. 1493 * @param logger logger, may not be null. 1494 * @param level level, may not be null. 1495 * @param bundleName resource bundle name, may be null. 1496 * @param key key, may be null. 1497 * @param param1 Parameter to the log message. 1498 */ 1499 public static void logrb(final Logger logger, 1500 final Level level, 1501 final String bundleName, 1502 final String key, 1503 final byte param1) { 1504 if (logger.isEnabledFor(level)) { 1505 forcedLog(logger, level, 1506 format(bundleName, key, toArray(valueOf(param1)))); 1507 } 1508 } 1509 1510 /** 1511 * Log a parameterized message using a pattern from a resource bundle. 1512 * @param logger logger, may not be null. 1513 * @param level level, may not be null. 1514 * @param bundleName resource bundle name, may be null. 1515 * @param key key, may be null. 1516 * @param param1 Parameter to the log message. 1517 */ 1518 public static void logrb(final Logger logger, 1519 final Level level, 1520 final String bundleName, 1521 final String key, 1522 final short param1) { 1523 if (logger.isEnabledFor(level)) { 1524 forcedLog(logger, level, 1525 format(bundleName, key, toArray(valueOf(param1)))); 1526 } 1527 } 1528 1529 /** 1530 * Log a parameterized message using a pattern from a resource bundle. 1531 * @param logger logger, may not be null. 1532 * @param level level, may not be null. 1533 * @param bundleName resource bundle name, may be null. 1534 * @param key key, may be null. 1535 * @param param1 Parameter to the log message. 1536 */ 1537 public static void logrb(final Logger logger, 1538 final Level level, 1539 final String bundleName, 1540 final String key, 1541 final int param1) { 1542 if (logger.isEnabledFor(level)) { 1543 forcedLog(logger, level, 1544 format(bundleName, key, toArray(valueOf(param1)))); 1545 } 1546 } 1547 1548 /** 1549 * Log a parameterized message using a pattern from a resource bundle. 1550 * @param logger logger, may not be null. 1551 * @param level level, may not be null. 1552 * @param bundleName resource bundle name, may be null. 1553 * @param key key, may be null. 1554 * @param param1 Parameter to the log message. 1555 */ 1556 public static void logrb(final Logger logger, 1557 final Level level, 1558 final String bundleName, 1559 final String key, 1560 final long param1) { 1561 if (logger.isEnabledFor(level)) { 1562 forcedLog(logger, level, 1563 format(bundleName, key, toArray(valueOf(param1)))); 1564 } 1565 } 1566 /** 1567 * Log a parameterized message using a pattern from a resource bundle. 1568 * @param logger logger, may not be null. 1569 * @param level level, may not be null. 1570 * @param bundleName resource bundle name, may be null. 1571 * @param key key, may be null. 1572 * @param param1 Parameter to the log message. 1573 */ 1574 public static void logrb(final Logger logger, 1575 final Level level, 1576 final String bundleName, 1577 final String key, 1578 final float param1) { 1579 if (logger.isEnabledFor(level)) { 1580 forcedLog(logger, level, 1581 format(bundleName, key, toArray(valueOf(param1)))); 1582 } 1583 } 1584 1585 1586 /** 1587 * Log a parameterized message using a pattern from a resource bundle. 1588 * @param logger logger, may not be null. 1589 * @param level level, may not be null. 1590 * @param bundleName resource bundle name, may be null. 1591 * @param key key, may be null. 1592 * @param param1 Parameter to the log message. 1593 */ 1594 public static void logrb(final Logger logger, 1595 final Level level, 1596 final String bundleName, 1597 final String key, 1598 final double param1) { 1599 if (logger.isEnabledFor(level)) { 1600 forcedLog(logger, level, 1601 format(bundleName, key, toArray(valueOf(param1)))); 1602 } 1603 } 1604 1605 /** 1606 * Log a parameterized message using a pattern from a resource bundle. 1607 * @param logger logger, may not be null. 1608 * @param level level, may not be null. 1609 * @param bundleName resource bundle name, may be null. 1610 * @param key key, may be null. 1611 * @param param0 Parameter to the log message. 1612 * @param param1 Parameter to the log message. 1613 */ 1614 public static void logrb(final Logger logger, 1615 final Level level, 1616 final String bundleName, 1617 final String key, 1618 final Object param0, 1619 final Object param1) { 1620 if (logger.isEnabledFor(level)) { 1621 forcedLog(logger, level, 1622 format(bundleName, key, toArray(param0, param1))); 1623 } 1624 } 1625 1626 1627 /** 1628 * Log a parameterized message using a pattern from a resource bundle. 1629 * @param logger logger, may not be null. 1630 * @param level level, may not be null. 1631 * @param bundleName resource bundle name, may be null. 1632 * @param key key, may be null. 1633 * @param param0 Parameter to the log message. 1634 * @param param1 Parameter to the log message. 1635 * @param param2 Parameter to the log message. 1636 */ 1637 public static void logrb(final Logger logger, 1638 final Level level, 1639 final String bundleName, 1640 final String key, 1641 final Object param0, 1642 final Object param1, 1643 final Object param2) { 1644 if (logger.isEnabledFor(level)) { 1645 forcedLog(logger, level, 1646 format(bundleName, key, toArray(param0, param1, param2))); 1647 } 1648 } 1649 1650 1651 /** 1652 * Log a parameterized message using a pattern from a resource bundle. 1653 * @param logger logger, may not be null. 1654 * @param level level, may not be null. 1655 * @param bundleName resource bundle name, may be null. 1656 * @param key key, may be null. 1657 * @param param0 Parameter to the log message. 1658 * @param param1 Parameter to the log message. 1659 * @param param2 Parameter to the log message. 1660 * @param param3 Parameter to the log message. 1661 */ 1662 public static void logrb(final Logger logger, 1663 final Level level, 1664 final String bundleName, 1665 final String key, 1666 final Object param0, 1667 final Object param1, 1668 final Object param2, 1669 final Object param3) { 1670 if (logger.isEnabledFor(level)) { 1671 forcedLog(logger, level, 1672 format(bundleName, key, 1673 toArray(param0, param1, param2, param3))); 1674 } 1675 } 1676 1677}