2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package org.apache.log4j;
19 import org.apache.log4j.spi.LoggingEvent;
21 import java.util.ResourceBundle;
25 * This class provides parameterized logging services
26 * using the SLF4J pattern syntax.
28 * Message formatting is only performed when the
29 * request exceeds the threshold level of the logger.
34 public final class LogSF extends LogXF {
36 * private constructor.
46 * Formats arguments using SLF4J-like formatter.
47 * @param pattern pattern, may be malformed.
48 * @param arguments arguments.
49 * @return Message string
51 private static String format(final String pattern,
52 final Object[] arguments) {
53 if (pattern != null) {
57 int pos = pattern.indexOf("{");
59 if (pos == 0 || pattern.charAt(pos-1) != '\\') {
60 retval += pattern.substring(prev, pos);
61 if (pos + 1 < pattern.length() && pattern.charAt(pos+1) == '}') {
62 if(arguments != null && count < arguments.length) {
63 retval += arguments[count++];
73 retval += pattern.substring(prev, pos - 1) + "{";
76 pos = pattern.indexOf("{", prev);
78 return retval + pattern.substring(prev);
84 * Formats arguments using MessageFormat.
85 * @param pattern pattern, may be malformed.
86 * @param arg0 argument, may be null or mismatched.
87 * @return Message string
89 private static String format(final String pattern, final Object arg0) {
90 if (pattern != null) {
92 // if there is an escaped brace, delegate to multi-param formatter
93 if (pattern.indexOf("\\{") >= 0) {
94 return format(pattern, new Object[] { arg0 });
96 int pos = pattern.indexOf("{}");
98 return pattern.substring(0, pos) + arg0 + pattern.substring(pos+2);
105 * Formats arguments using MessageFormat using a pattern from
107 * @param resourceBundleName name of resource bundle, may be null.
108 * @param key key for pattern in resource bundle, may be null.
109 * @param arguments arguments, may be null or mismatched.
110 * @return Message string or null
112 private static String format(
113 final String resourceBundleName,
115 final Object[] arguments) {
117 if (resourceBundleName != null) {
119 ResourceBundle bundle =
120 ResourceBundle.getBundle(resourceBundleName);
121 pattern = bundle.getString(key);
122 } catch (Exception ex) {
128 return format(pattern, arguments);
133 * Fully Qualified Class Name of this class.
135 private static final String FQCN = LogSF.class.getName();
138 * Equivalent of Logger.forcedLog.
140 * @param logger logger, may not be null.
141 * @param level level, may not be null.
142 * @param msg message, may be null.
144 private static void forcedLog(final Logger logger,
147 logger.callAppenders(new LoggingEvent(FQCN, logger, level, msg, null));
151 * Equivalent of Logger.forcedLog.
153 * @param logger logger, may not be null.
154 * @param level level, may not be null.
155 * @param msg message, may be null.
156 * @param t throwable.
158 private static void forcedLog(final Logger logger,
162 logger.callAppenders(new LoggingEvent(FQCN, logger, level, msg, t));
165 * Log a parameterized message at trace level.
166 * @param logger logger, may not be null.
167 * @param pattern pattern, may be null.
168 * @param arguments an array of arguments to be
169 * formatted and substituted.
171 public static void trace(final Logger logger, final String pattern,
172 final Object[] arguments) {
173 if (logger.isEnabledFor(TRACE)) {
174 forcedLog(logger, TRACE, format(pattern, arguments));
179 * Log a parameterized message at debug level.
180 * @param logger logger, may not be null.
181 * @param pattern pattern, may be null.
182 * @param arguments an array of arguments to be formatted and substituted.
184 public static void debug(final Logger logger, final String pattern,
185 final Object[] arguments) {
186 if (logger.isDebugEnabled()) {
187 forcedLog(logger, Level.DEBUG, format(pattern, arguments));
192 * Log a parameterized message at info level.
193 * @param logger logger, may not be null.
194 * @param pattern pattern, may be null.
195 * @param arguments an array of arguments to be formatted and substituted.
197 public static void info(final Logger logger, final String pattern,
198 final Object[] arguments) {
199 if (logger.isInfoEnabled()) {
200 forcedLog(logger, Level.INFO, format(pattern, arguments));
205 * Log a parameterized message at warn level.
206 * @param logger logger, may not be null.
207 * @param pattern pattern, may be null.
208 * @param arguments an array of arguments to be formatted and substituted.
210 public static void warn(final Logger logger, final String pattern,
211 final Object[] arguments) {
212 if (logger.isEnabledFor(Level.WARN)) {
213 forcedLog(logger, Level.WARN, format(pattern, arguments));
218 * Log a parameterized message at error level.
219 * @param logger logger, may not be null.
220 * @param pattern pattern, may be null.
221 * @param arguments an array of arguments to be formatted and substituted.
223 public static void error(final Logger logger, final String pattern,
224 final Object[] arguments) {
225 if (logger.isEnabledFor(Level.ERROR)) {
226 forcedLog(logger, Level.ERROR, format(pattern, arguments));
231 * Log a parameterized message at fatal level.
232 * @param logger logger, may not be null.
233 * @param pattern pattern, may be null.
234 * @param arguments an array of arguments to be formatted and substituted.
236 public static void fatal(final Logger logger, final String pattern,
237 final Object[] arguments) {
238 if (logger.isEnabledFor(Level.FATAL)) {
239 forcedLog(logger, Level.FATAL, format(pattern, arguments));
244 * Log a parameterized message at trace level.
245 * @param logger logger, may not be null.
246 * @param t throwable, may be null.
247 * @param pattern pattern, may be null.
248 * @param arguments an array of arguments to be
249 * formatted and substituted.
251 public static void trace(final Logger logger,
253 final String pattern,
254 final Object[] arguments) {
255 if (logger.isEnabledFor(TRACE)) {
256 forcedLog(logger, TRACE, format(pattern, arguments), t);
261 * Log a parameterized message at debug level.
262 * @param logger logger, may not be null.
263 * @param t throwable, may be null.
264 * @param pattern pattern, may be null.
265 * @param arguments an array of arguments to be formatted and substituted.
267 public static void debug(final Logger logger,
269 final String pattern,
270 final Object[] arguments) {
271 if (logger.isDebugEnabled()) {
272 forcedLog(logger, Level.DEBUG, format(pattern, arguments), t);
277 * Log a parameterized message at info level.
278 * @param logger logger, may not be null.
279 * @param t throwable, may be null.
280 * @param pattern pattern, may be null.
281 * @param arguments an array of arguments to be formatted and substituted.
283 public static void info(final Logger logger,
285 final String pattern,
286 final Object[] arguments) {
287 if (logger.isInfoEnabled()) {
288 forcedLog(logger, Level.INFO, format(pattern, arguments), t);
293 * Log a parameterized message at warn level.
294 * @param logger logger, may not be null.
295 * @param t throwable, may be null.
296 * @param pattern pattern, may be null.
297 * @param arguments an array of arguments to be formatted and substituted.
299 public static void warn(final Logger logger,
301 final String pattern,
302 final Object[] arguments) {
303 if (logger.isEnabledFor(Level.WARN)) {
304 forcedLog(logger, Level.WARN, format(pattern, arguments), t);
309 * Log a parameterized message at error level.
310 * @param logger logger, may not be null.
311 * @param t throwable, may be null.
312 * @param pattern pattern, may be null.
313 * @param arguments an array of arguments to be formatted and substituted.
315 public static void error(final Logger logger,
317 final String pattern,
318 final Object[] arguments) {
319 if (logger.isEnabledFor(Level.ERROR)) {
320 forcedLog(logger, Level.ERROR, format(pattern, arguments), t);
325 * Log a parameterized message at fatal level.
326 * @param logger logger, may not be null.
327 * @param t throwable, may be null.
328 * @param pattern pattern, may be null.
329 * @param arguments an array of arguments to be formatted and substituted.
331 public static void fatal(final Logger logger,
333 final String pattern,
334 final Object[] arguments) {
335 if (logger.isEnabledFor(Level.FATAL)) {
336 forcedLog(logger, Level.FATAL, format(pattern, arguments), t);
343 * Log a parameterized message at trace level.
344 * @param logger logger, may not be null.
345 * @param pattern pattern, may be null.
346 * @param argument a value to be formatted and substituted.
348 public static void trace(final Logger logger, final String pattern,
349 final boolean argument) {
350 if (logger.isEnabledFor(TRACE)) {
351 forcedLog(logger, TRACE, format(pattern, valueOf(argument)));
356 * Log a parameterized message at trace level.
357 * @param logger logger, may not be null.
358 * @param pattern pattern, may be null.
359 * @param argument a value to be formatted and substituted.
361 public static void trace(final Logger logger, final String pattern,
362 final char argument) {
363 if (logger.isEnabledFor(TRACE)) {
364 forcedLog(logger, TRACE, format(pattern, valueOf(argument)));
369 * Log a parameterized message at trace level.
370 * @param logger logger, may not be null.
371 * @param pattern pattern, may be null.
372 * @param argument a value to be formatted and substituted.
374 public static void trace(final Logger logger, final String pattern,
375 final byte argument) {
376 if (logger.isEnabledFor(TRACE)) {
377 forcedLog(logger, TRACE, format(pattern, valueOf(argument)));
382 * Log a parameterized message at trace level.
383 * @param logger logger, may not be null.
384 * @param pattern pattern, may be null.
385 * @param argument a value to be formatted and substituted.
387 public static void trace(final Logger logger, final String pattern,
388 final short argument) {
389 if (logger.isEnabledFor(TRACE)) {
390 forcedLog(logger, TRACE, format(pattern, valueOf(argument)));
395 * Log a parameterized message at trace level.
396 * @param logger logger, may not be null.
397 * @param pattern pattern, may be null.
398 * @param argument a value to be formatted and substituted.
400 public static void trace(final Logger logger, final String pattern,
401 final int argument) {
402 if (logger.isEnabledFor(TRACE)) {
403 forcedLog(logger, TRACE, format(pattern, valueOf(argument)));
408 * Log a parameterized message at trace level.
409 * @param logger logger, may not be null.
410 * @param pattern pattern, may be null.
411 * @param argument a value to be formatted and substituted.
413 public static void trace(final Logger logger, final String pattern,
414 final long argument) {
415 if (logger.isEnabledFor(TRACE)) {
416 forcedLog(logger, TRACE, format(pattern, valueOf(argument)));
421 * Log a parameterized message at trace level.
422 * @param logger logger, may not be null.
423 * @param pattern pattern, may be null.
424 * @param argument a value to be formatted and substituted.
426 public static void trace(final Logger logger, final String pattern,
427 final float argument) {
428 if (logger.isEnabledFor(TRACE)) {
429 forcedLog(logger, TRACE, format(pattern, valueOf(argument)));
434 * Log a parameterized message at trace level.
435 * @param logger logger, may not be null.
436 * @param pattern pattern, may be null.
437 * @param argument a value to be formatted and substituted.
439 public static void trace(final Logger logger, final String pattern,
440 final double argument) {
441 if (logger.isEnabledFor(TRACE)) {
442 forcedLog(logger, TRACE, format(pattern, valueOf(argument)));
447 * Log a parameterized message at trace level.
448 * @param logger logger, may not be null.
449 * @param pattern pattern, may be null.
450 * @param argument a value to be formatted and substituted.
452 public static void trace(final Logger logger, final String pattern,
453 final Object argument) {
454 if (logger.isEnabledFor(TRACE)) {
455 forcedLog(logger, TRACE, format(pattern, argument));
460 * Log a parameterized message at trace level.
461 * @param logger logger, may not be null.
462 * @param pattern pattern, may be null.
463 * @param arg0 a value to be formatted and substituted.
464 * @param arg1 a value to be formatted and substituted.
466 public static void trace(final Logger logger, final String pattern,
467 final Object arg0, final Object arg1) {
468 if (logger.isEnabledFor(TRACE)) {
469 forcedLog(logger, TRACE,
470 format(pattern, toArray(arg0, arg1)));
475 * Log a parameterized message at trace level.
476 * @param logger logger, may not be null.
477 * @param pattern pattern, may be null.
478 * @param arg0 a value to be formatted and substituted.
479 * @param arg1 a value to be formatted and substituted.
480 * @param arg2 a value to be formatted and substituted.
482 public static void trace(final Logger logger, final String pattern,
483 final Object arg0, final Object arg1, final Object arg2) {
484 if (logger.isEnabledFor(TRACE)) {
485 forcedLog(logger, TRACE,
486 format(pattern, toArray(arg0, arg1, arg2)));
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 arg0 a value to be formatted and substituted.
495 * @param arg1 a value to be formatted and substituted.
496 * @param arg2 a value to be formatted and substituted.
497 * @param arg3 a value to be formatted and substituted.
499 public static void trace(final Logger logger, final String pattern,
500 final Object arg0, final Object arg1, final Object arg2,
502 if (logger.isEnabledFor(TRACE)) {
503 forcedLog(logger, TRACE,
504 format(pattern, toArray(arg0, arg1, arg2, arg3)));
509 * Log a parameterized message at debug level.
510 * @param logger logger, may not be null.
511 * @param pattern pattern, may be null.
512 * @param argument a value to be formatted and substituted.
514 public static void debug(final Logger logger, final String pattern,
515 final boolean argument) {
516 if (logger.isDebugEnabled()) {
517 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument)));
522 * Log a parameterized message at debug level.
523 * @param logger logger, may not be null.
524 * @param pattern pattern, may be null.
525 * @param argument a value to be formatted and substituted.
527 public static void debug(final Logger logger, final String pattern,
528 final char argument) {
529 if (logger.isDebugEnabled()) {
530 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument)));
535 * Log a parameterized message at debug level.
536 * @param logger logger, may not be null.
537 * @param pattern pattern, may be null.
538 * @param argument a value to be formatted and substituted.
540 public static void debug(final Logger logger, final String pattern,
541 final byte argument) {
542 if (logger.isDebugEnabled()) {
543 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument)));
548 * Log a parameterized message at debug level.
549 * @param logger logger, may not be null.
550 * @param pattern pattern, may be null.
551 * @param argument a value to be formatted and substituted.
553 public static void debug(final Logger logger, final String pattern,
554 final short argument) {
555 if (logger.isDebugEnabled()) {
556 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument)));
561 * Log a parameterized message at debug level.
562 * @param logger logger, may not be null.
563 * @param pattern pattern, may be null.
564 * @param argument a value to be formatted and substituted.
566 public static void debug(final Logger logger, final String pattern,
567 final int argument) {
568 if (logger.isDebugEnabled()) {
569 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument)));
574 * Log a parameterized message at debug level.
575 * @param logger logger, may not be null.
576 * @param pattern pattern, may be null.
577 * @param argument a value to be formatted and substituted.
579 public static void debug(final Logger logger, final String pattern,
580 final long argument) {
581 if (logger.isDebugEnabled()) {
582 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument)));
587 * Log a parameterized message at debug level.
588 * @param logger logger, may not be null.
589 * @param pattern pattern, may be null.
590 * @param argument a value to be formatted and substituted.
592 public static void debug(final Logger logger, final String pattern,
593 final float argument) {
594 if (logger.isDebugEnabled()) {
595 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument)));
600 * Log a parameterized message at debug level.
601 * @param logger logger, may not be null.
602 * @param pattern pattern, may be null.
603 * @param argument a value to be formatted and substituted.
605 public static void debug(final Logger logger, final String pattern,
606 final double argument) {
607 if (logger.isDebugEnabled()) {
608 forcedLog(logger, Level.DEBUG, format(pattern, valueOf(argument)));
613 * Log a parameterized message at debug level.
614 * @param logger logger, may not be null.
615 * @param pattern pattern, may be null.
616 * @param argument a value to be formatted and substituted.
618 public static void debug(final Logger logger, final String pattern,
619 final Object argument) {
620 if (logger.isDebugEnabled()) {
621 forcedLog(logger, Level.DEBUG, format(pattern, argument));
626 * Log a parameterized message at debug 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.
632 public static void debug(final Logger logger, final String pattern,
633 final Object arg0, final Object arg1) {
634 if (logger.isDebugEnabled()) {
635 forcedLog(logger, Level.DEBUG,
636 format(pattern, toArray(arg0, arg1)));
641 * Log a parameterized message at debug level.
642 * @param logger logger, may not be null.
643 * @param pattern pattern, may be null.
644 * @param arg0 a value to be formatted and substituted.
645 * @param arg1 a value to be formatted and substituted.
646 * @param arg2 a value to be formatted and substituted.
648 public static void debug(final Logger logger, final String pattern,
649 final Object arg0, final Object arg1, final Object arg2) {
650 if (logger.isDebugEnabled()) {
651 forcedLog(logger, Level.DEBUG,
652 format(pattern, toArray(arg0, arg1, arg2)));
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 arg0 a value to be formatted and substituted.
661 * @param arg1 a value to be formatted and substituted.
662 * @param arg2 a value to be formatted and substituted.
663 * @param arg3 a value to be formatted and substituted.
665 public static void debug(final Logger logger, final String pattern,
666 final Object arg0, final Object arg1, final Object arg2,
668 if (logger.isDebugEnabled()) {
669 forcedLog(logger, Level.DEBUG,
670 format(pattern, toArray(arg0, arg1, arg2, arg3)));
675 * Log a parameterized message at info level.
676 * @param logger logger, may not be null.
677 * @param pattern pattern, may be null.
678 * @param argument a value to be formatted and substituted.
680 public static void info(final Logger logger, final String pattern,
681 final boolean argument) {
682 if (logger.isInfoEnabled()) {
683 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument)));
688 * Log a parameterized message at info level.
689 * @param logger logger, may not be null.
690 * @param pattern pattern, may be null.
691 * @param argument a value to be formatted and substituted.
693 public static void info(final Logger logger, final String pattern,
694 final char argument) {
695 if (logger.isInfoEnabled()) {
696 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument)));
701 * Log a parameterized message at info level.
702 * @param logger logger, may not be null.
703 * @param pattern pattern, may be null.
704 * @param argument a value to be formatted and substituted.
706 public static void info(final Logger logger, final String pattern,
707 final byte argument) {
708 if (logger.isInfoEnabled()) {
709 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument)));
714 * Log a parameterized message at info level.
715 * @param logger logger, may not be null.
716 * @param pattern pattern, may be null.
717 * @param argument a value to be formatted and substituted.
719 public static void info(final Logger logger, final String pattern,
720 final short argument) {
721 if (logger.isInfoEnabled()) {
722 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument)));
727 * Log a parameterized message at info level.
728 * @param logger logger, may not be null.
729 * @param pattern pattern, may be null.
730 * @param argument a value to be formatted and substituted.
732 public static void info(final Logger logger, final String pattern,
733 final int argument) {
734 if (logger.isInfoEnabled()) {
735 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument)));
740 * Log a parameterized message at info level.
741 * @param logger logger, may not be null.
742 * @param pattern pattern, may be null.
743 * @param argument a value to be formatted and substituted.
745 public static void info(final Logger logger, final String pattern,
746 final long argument) {
747 if (logger.isInfoEnabled()) {
748 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument)));
753 * Log a parameterized message at info level.
754 * @param logger logger, may not be null.
755 * @param pattern pattern, may be null.
756 * @param argument a value to be formatted and substituted.
758 public static void info(final Logger logger, final String pattern,
759 final float argument) {
760 if (logger.isInfoEnabled()) {
761 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument)));
766 * Log a parameterized message at info level.
767 * @param logger logger, may not be null.
768 * @param pattern pattern, may be null.
769 * @param argument a value to be formatted and substituted.
771 public static void info(final Logger logger, final String pattern,
772 final double argument) {
773 if (logger.isInfoEnabled()) {
774 forcedLog(logger, Level.INFO, format(pattern, valueOf(argument)));
779 * Log a parameterized message at info level.
780 * @param logger logger, may not be null.
781 * @param pattern pattern, may be null.
782 * @param argument a value to be formatted and substituted.
784 public static void info(final Logger logger, final String pattern,
785 final Object argument) {
786 if (logger.isInfoEnabled()) {
787 forcedLog(logger, Level.INFO, format(pattern, argument));
792 * Log a parameterized message at info 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.
798 public static void info(final Logger logger, final String pattern,
799 final Object arg0, final Object arg1) {
800 if (logger.isInfoEnabled()) {
801 forcedLog(logger, Level.INFO, format(pattern, toArray(arg0, arg1)));
806 * Log a parameterized message at info level.
807 * @param logger logger, may not be null.
808 * @param pattern pattern, may be null.
809 * @param arg0 a value to be formatted and substituted.
810 * @param arg1 a value to be formatted and substituted.
811 * @param arg2 a value to be formatted and substituted.
813 public static void info(final Logger logger, final String pattern,
814 final Object arg0, final Object arg1, final Object arg2) {
815 if (logger.isInfoEnabled()) {
816 forcedLog(logger, Level.INFO, format(pattern,
817 toArray(arg0, arg1, arg2)));
822 * Log a parameterized message at info level.
823 * @param logger logger, may not be null.
824 * @param pattern pattern, may be null.
825 * @param arg0 a value to be formatted and substituted.
826 * @param arg1 a value to be formatted and substituted.
827 * @param arg2 a value to be formatted and substituted.
828 * @param arg3 a value to be formatted and substituted.
830 public static void info(final Logger logger, final String pattern,
831 final Object arg0, final Object arg1, final Object arg2,
833 if (logger.isInfoEnabled()) {
834 forcedLog(logger, Level.INFO, format(pattern,
835 toArray(arg0, arg1, arg2, arg3)));
840 * Log a parameterized message at warn level.
841 * @param logger logger, may not be null.
842 * @param pattern pattern, may be null.
843 * @param argument a value to be formatted and substituted.
845 public static void warn(final Logger logger, final String pattern,
846 final boolean argument) {
847 if (logger.isEnabledFor(Level.WARN)) {
848 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument)));
853 * Log a parameterized message at warn level.
854 * @param logger logger, may not be null.
855 * @param pattern pattern, may be null.
856 * @param argument a value to be formatted and substituted.
858 public static void warn(final Logger logger, final String pattern,
859 final char argument) {
860 if (logger.isEnabledFor(Level.WARN)) {
861 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument)));
866 * Log a parameterized message at warn level.
867 * @param logger logger, may not be null.
868 * @param pattern pattern, may be null.
869 * @param argument a value to be formatted and substituted.
871 public static void warn(final Logger logger, final String pattern,
872 final byte argument) {
873 if (logger.isEnabledFor(Level.WARN)) {
874 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument)));
879 * Log a parameterized message at warn level.
880 * @param logger logger, may not be null.
881 * @param pattern pattern, may be null.
882 * @param argument a value to be formatted and substituted.
884 public static void warn(final Logger logger, final String pattern,
885 final short argument) {
886 if (logger.isEnabledFor(Level.WARN)) {
887 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument)));
892 * Log a parameterized message at warn level.
893 * @param logger logger, may not be null.
894 * @param pattern pattern, may be null.
895 * @param argument a value to be formatted and substituted.
897 public static void warn(final Logger logger, final String pattern,
898 final int argument) {
899 if (logger.isEnabledFor(Level.WARN)) {
900 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument)));
905 * Log a parameterized message at warn level.
906 * @param logger logger, may not be null.
907 * @param pattern pattern, may be null.
908 * @param argument a value to be formatted and substituted.
910 public static void warn(final Logger logger, final String pattern,
911 final long argument) {
912 if (logger.isEnabledFor(Level.WARN)) {
913 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument)));
918 * Log a parameterized message at warn level.
919 * @param logger logger, may not be null.
920 * @param pattern pattern, may be null.
921 * @param argument a value to be formatted and substituted.
923 public static void warn(final Logger logger, final String pattern,
924 final float argument) {
925 if (logger.isEnabledFor(Level.WARN)) {
926 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument)));
931 * Log a parameterized message at warn level.
932 * @param logger logger, may not be null.
933 * @param pattern pattern, may be null.
934 * @param argument a value to be formatted and substituted.
936 public static void warn(final Logger logger, final String pattern,
937 final double argument) {
938 if (logger.isEnabledFor(Level.WARN)) {
939 forcedLog(logger, Level.WARN, format(pattern, valueOf(argument)));
944 * Log a parameterized message at warn level.
945 * @param logger logger, may not be null.
946 * @param pattern pattern, may be null.
947 * @param argument a value to be formatted and substituted.
949 public static void warn(final Logger logger, final String pattern,
950 final Object argument) {
951 if (logger.isEnabledFor(Level.WARN)) {
952 forcedLog(logger, Level.WARN, format(pattern, argument));
957 * Log a parameterized message at warn 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.
963 public static void warn(final Logger logger, final String pattern,
964 final Object arg0, final Object arg1) {
965 if (logger.isEnabledFor(Level.WARN)) {
966 forcedLog(logger, Level.WARN,
967 format(pattern, toArray(arg0, arg1)));
972 * Log a parameterized message at warn level.
973 * @param logger logger, may not be null.
974 * @param pattern pattern, may be null.
975 * @param arg0 a value to be formatted and substituted.
976 * @param arg1 a value to be formatted and substituted.
977 * @param arg2 a value to be formatted and substituted.
979 public static void warn(final Logger logger, final String pattern,
980 final Object arg0, final Object arg1, final Object arg2) {
981 if (logger.isEnabledFor(Level.WARN)) {
982 forcedLog(logger, Level.WARN,
983 format(pattern, toArray(arg0, arg1, arg2)));
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 arg0 a value to be formatted and substituted.
992 * @param arg1 a value to be formatted and substituted.
993 * @param arg2 a value to be formatted and substituted.
994 * @param arg3 a value to be formatted and substituted.
996 public static void warn(final Logger logger, final String pattern,
997 final Object arg0, final Object arg1, final Object arg2,
999 if (logger.isEnabledFor(Level.WARN)) {
1000 forcedLog(logger, Level.WARN, format(pattern,
1001 toArray(arg0, arg1, arg2, arg3)));
1006 * Log a parameterized message at specified level.
1007 * @param logger logger, may not be null.
1008 * @param level level, may not be null.
1009 * @param pattern pattern, may be null.
1010 * @param parameters parameters to the log message.
1012 public static void log(final Logger logger,
1014 final String pattern,
1015 final Object[] parameters) {
1016 if (logger.isEnabledFor(level)) {
1017 forcedLog(logger, level,
1018 format(pattern, parameters));
1023 * Log a parameterized message at specified level.
1024 * @param logger logger, may not be null.
1025 * @param level level, may not be null.
1026 * @param t throwable, may be null.
1027 * @param pattern pattern, may be null.
1028 * @param parameters parameters to the log message.
1030 public static void log(final Logger logger,
1033 final String pattern,
1034 final Object[] parameters) {
1035 if (logger.isEnabledFor(level)) {
1036 forcedLog(logger, level,
1037 format(pattern, parameters), t);
1042 * Log a parameterized message at specified level.
1043 * @param logger logger, may not be null.
1044 * @param level level, may not be null.
1045 * @param pattern pattern, may be null.
1046 * @param param1 parameter to the log message.
1048 public static void log(final Logger logger,
1050 final String pattern,
1051 final Object param1) {
1052 if (logger.isEnabledFor(level)) {
1053 forcedLog(logger, level,
1054 format(pattern, toArray(param1)));
1059 * Log a parameterized message at specified level.
1060 * @param logger logger, may not be null.
1061 * @param level level, may not be null.
1062 * @param pattern pattern, may be null.
1063 * @param param1 parameter to the log message.
1065 public static void log(final Logger logger,
1067 final String pattern,
1068 final boolean param1) {
1069 if (logger.isEnabledFor(level)) {
1070 forcedLog(logger, level,
1071 format(pattern, toArray(valueOf(param1))));
1077 * Log a parameterized message at specified level.
1078 * @param logger logger, may not be null.
1079 * @param level level, may not be null.
1080 * @param pattern pattern, may be null.
1081 * @param param1 parameter to the log message.
1083 public static void log(final Logger logger,
1085 final String pattern,
1086 final byte param1) {
1087 if (logger.isEnabledFor(level)) {
1088 forcedLog(logger, level,
1089 format(pattern, toArray(valueOf(param1))));
1095 * Log a parameterized message at specified level.
1096 * @param logger logger, may not be null.
1097 * @param level level, may not be null.
1098 * @param pattern pattern, may be null.
1099 * @param param1 parameter to the log message.
1101 public static void log(final Logger logger,
1103 final String pattern,
1104 final char param1) {
1105 if (logger.isEnabledFor(level)) {
1106 forcedLog(logger, level,
1107 format(pattern, toArray(valueOf(param1))));
1112 * Log a parameterized message at specified level.
1113 * @param logger logger, may not be null.
1114 * @param level level, may not be null.
1115 * @param pattern pattern, may be null.
1116 * @param param1 parameter to the log message.
1118 public static void log(final Logger logger,
1120 final String pattern,
1121 final short param1) {
1122 if (logger.isEnabledFor(level)) {
1123 forcedLog(logger, level,
1124 format(pattern, toArray(valueOf(param1))));
1129 * Log a parameterized message at specified level.
1130 * @param logger logger, may not be null.
1131 * @param level level, may not be null.
1132 * @param pattern pattern, may be null.
1133 * @param param1 parameter to the log message.
1135 public static void log(final Logger logger,
1137 final String pattern,
1139 if (logger.isEnabledFor(level)) {
1140 forcedLog(logger, level,
1141 format(pattern, toArray(valueOf(param1))));
1147 * Log a parameterized message at specified level.
1148 * @param logger logger, may not be null.
1149 * @param level level, may not be null.
1150 * @param pattern pattern, may be null.
1151 * @param param1 parameter to the log message.
1153 public static void log(final Logger logger,
1155 final String pattern,
1156 final long param1) {
1157 if (logger.isEnabledFor(level)) {
1158 forcedLog(logger, level,
1159 format(pattern, toArray(valueOf(param1))));
1165 * Log a parameterized message at specified level.
1166 * @param logger logger, may not be null.
1167 * @param level level, may not be null.
1168 * @param pattern pattern, may be null.
1169 * @param param1 parameter to the log message.
1171 public static void log(final Logger logger,
1173 final String pattern,
1174 final float param1) {
1175 if (logger.isEnabledFor(level)) {
1176 forcedLog(logger, level,
1177 format(pattern, toArray(valueOf(param1))));
1183 * Log a parameterized message at specified level.
1184 * @param logger logger, may not be null.
1185 * @param level level, may not be null.
1186 * @param pattern pattern, may be null.
1187 * @param param1 parameter to the log message.
1189 public static void log(final Logger logger,
1191 final String pattern,
1192 final double param1) {
1193 if (logger.isEnabledFor(level)) {
1194 forcedLog(logger, level,
1195 format(pattern, toArray(valueOf(param1))));
1201 * Log a parameterized message at specified level.
1202 * @param logger logger, may not be null.
1203 * @param level level, may not be null.
1204 * @param pattern pattern, may be null.
1205 * @param arg0 a value to be formatted and substituted.
1206 * @param arg1 a value to be formatted and substituted.
1208 public static void log(final Logger logger,
1210 final String pattern,
1211 final Object arg0, final Object arg1) {
1212 if (logger.isEnabledFor(level)) {
1213 forcedLog(logger, level,
1214 format(pattern, toArray(arg0, arg1)));
1219 * Log a parameterized message at specifed level.
1220 * @param logger logger, may not be null.
1221 * @param level level, may not be null.
1222 * @param pattern pattern, may be null.
1223 * @param arg0 a value to be formatted and substituted.
1224 * @param arg1 a value to be formatted and substituted.
1225 * @param arg2 a value to be formatted and substituted.
1227 public static void log(final Logger logger,
1229 final String pattern,
1230 final Object arg0, final Object arg1, final Object arg2) {
1231 if (logger.isEnabledFor(level)) {
1232 forcedLog(logger, level,
1233 format(pattern, toArray(arg0, arg1, arg2)));
1238 * Log a parameterized message at specified level.
1239 * @param logger logger, may not be null.
1240 * @param pattern pattern, may be null.
1241 * @param level level, may not be null.
1242 * @param arg0 a value to be formatted and substituted.
1243 * @param arg1 a value to be formatted and substituted.
1244 * @param arg2 a value to be formatted and substituted.
1245 * @param arg3 a value to be formatted and substituted.
1247 public static void log(final Logger logger,
1249 final String pattern,
1250 final Object arg0, final Object arg1, final Object arg2,
1251 final Object arg3) {
1252 if (logger.isEnabledFor(level)) {
1253 forcedLog(logger, level, format(pattern,
1254 toArray(arg0, arg1, arg2, arg3)));
1260 * Log a parameterized message using a pattern from a resource bundle.
1261 * @param logger logger, may not be null.
1262 * @param level level, may not be null.
1263 * @param bundleName resource bundle name, may be null.
1264 * @param key key, may be null.
1265 * @param parameters parameters to the log message.
1267 public static void logrb(final Logger logger,
1269 final String bundleName,
1271 final Object[] parameters) {
1272 if (logger.isEnabledFor(level)) {
1273 forcedLog(logger, level,
1274 format(bundleName, key, parameters));
1279 * Log a parameterized message using a pattern from a resource bundle.
1280 * @param logger logger, may not be null.
1281 * @param level level, may not be null.
1282 * @param t throwable, may be null.
1283 * @param bundleName resource bundle name, may be null.
1284 * @param key key, may be null.
1285 * @param parameters parameters to the log message.
1287 public static void logrb(final Logger logger,
1290 final String bundleName,
1292 final Object[] parameters) {
1293 if (logger.isEnabledFor(level)) {
1294 forcedLog(logger, level,
1295 format(bundleName, key, parameters), t);
1300 * Log a parameterized message using a pattern from a resource bundle.
1301 * @param logger logger, may not be null.
1302 * @param level level, may not be null.
1303 * @param bundleName resource bundle name, may be null.
1304 * @param key key, may be null.
1305 * @param param1 Parameter to the log message.
1307 public static void logrb(final Logger logger,
1309 final String bundleName,
1311 final Object param1) {
1312 if (logger.isEnabledFor(level)) {
1313 forcedLog(logger, level,
1314 format(bundleName, key, toArray(param1)));
1319 * Log a parameterized message using a pattern from a resource bundle.
1320 * @param logger logger, may not be null.
1321 * @param level level, may not be null.
1322 * @param bundleName resource bundle name, may be null.
1323 * @param key key, may be null.
1324 * @param param1 Parameter to the log message.
1326 public static void logrb(final Logger logger,
1328 final String bundleName,
1330 final boolean param1) {
1331 if (logger.isEnabledFor(level)) {
1332 forcedLog(logger, level,
1333 format(bundleName, key, toArray(valueOf(param1))));
1338 * Log a parameterized message using a pattern from a resource bundle.
1339 * @param logger logger, may not be null.
1340 * @param level level, may not be null.
1341 * @param bundleName resource bundle name, may be null.
1342 * @param key key, may be null.
1343 * @param param1 Parameter to the log message.
1345 public static void logrb(final Logger logger,
1347 final String bundleName,
1349 final char param1) {
1350 if (logger.isEnabledFor(level)) {
1351 forcedLog(logger, level,
1352 format(bundleName, key, toArray(valueOf(param1))));
1357 * Log a parameterized message using a pattern from a resource bundle.
1358 * @param logger logger, may not be null.
1359 * @param level level, may not be null.
1360 * @param bundleName resource bundle name, may be null.
1361 * @param key key, may be null.
1362 * @param param1 Parameter to the log message.
1364 public static void logrb(final Logger logger,
1366 final String bundleName,
1368 final byte param1) {
1369 if (logger.isEnabledFor(level)) {
1370 forcedLog(logger, level,
1371 format(bundleName, key, toArray(valueOf(param1))));
1376 * Log a parameterized message using a pattern from a resource bundle.
1377 * @param logger logger, may not be null.
1378 * @param level level, may not be null.
1379 * @param bundleName resource bundle name, may be null.
1380 * @param key key, may be null.
1381 * @param param1 Parameter to the log message.
1383 public static void logrb(final Logger logger,
1385 final String bundleName,
1387 final short param1) {
1388 if (logger.isEnabledFor(level)) {
1389 forcedLog(logger, level,
1390 format(bundleName, key, toArray(valueOf(param1))));
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 param1 Parameter to the log message.
1402 public static void logrb(final Logger logger,
1404 final String bundleName,
1407 if (logger.isEnabledFor(level)) {
1408 forcedLog(logger, level,
1409 format(bundleName, key, toArray(valueOf(param1))));
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 bundleName resource bundle name, may be null.
1418 * @param key key, may be null.
1419 * @param param1 Parameter to the log message.
1421 public static void logrb(final Logger logger,
1423 final String bundleName,
1425 final long param1) {
1426 if (logger.isEnabledFor(level)) {
1427 forcedLog(logger, level,
1428 format(bundleName, key, toArray(valueOf(param1))));
1432 * Log a parameterized message using a pattern from a resource bundle.
1433 * @param logger logger, may not be null.
1434 * @param level level, may not be null.
1435 * @param bundleName resource bundle name, may be null.
1436 * @param key key, may be null.
1437 * @param param1 Parameter to the log message.
1439 public static void logrb(final Logger logger,
1441 final String bundleName,
1443 final float param1) {
1444 if (logger.isEnabledFor(level)) {
1445 forcedLog(logger, level,
1446 format(bundleName, key, toArray(valueOf(param1))));
1452 * Log a parameterized message using a pattern from a resource bundle.
1453 * @param logger logger, may not be null.
1454 * @param level level, may not be null.
1455 * @param bundleName resource bundle name, may be null.
1456 * @param key key, may be null.
1457 * @param param1 Parameter to the log message.
1459 public static void logrb(final Logger logger,
1461 final String bundleName,
1463 final double param1) {
1464 if (logger.isEnabledFor(level)) {
1465 forcedLog(logger, level,
1466 format(bundleName, key, toArray(valueOf(param1))));
1471 * Log a parameterized message using a pattern from a resource bundle.
1472 * @param logger logger, may not be null.
1473 * @param level level, may not be null.
1474 * @param bundleName resource bundle name, may be null.
1475 * @param key key, may be null.
1476 * @param param0 Parameter to the log message.
1477 * @param param1 Parameter to the log message.
1479 public static void logrb(final Logger logger,
1481 final String bundleName,
1483 final Object param0,
1484 final Object param1) {
1485 if (logger.isEnabledFor(level)) {
1486 forcedLog(logger, level,
1487 format(bundleName, key, toArray(param0, param1)));
1493 * Log a parameterized message using a pattern from a resource bundle.
1494 * @param logger logger, may not be null.
1495 * @param level level, may not be null.
1496 * @param bundleName resource bundle name, may be null.
1497 * @param key key, may be null.
1498 * @param param0 Parameter to the log message.
1499 * @param param1 Parameter to the log message.
1500 * @param param2 Parameter to the log message.
1502 public static void logrb(final Logger logger,
1504 final String bundleName,
1506 final Object param0,
1507 final Object param1,
1508 final Object param2) {
1509 if (logger.isEnabledFor(level)) {
1510 forcedLog(logger, level,
1511 format(bundleName, key, toArray(param0, param1, param2)));
1517 * Log a parameterized message using a pattern from a resource bundle.
1518 * @param logger logger, may not be null.
1519 * @param level level, may not be null.
1520 * @param bundleName resource bundle name, may be null.
1521 * @param key key, may be null.
1522 * @param param0 Parameter to the log message.
1523 * @param param1 Parameter to the log message.
1524 * @param param2 Parameter to the log message.
1525 * @param param3 Parameter to the log message.
1527 public static void logrb(final Logger logger,
1529 final String bundleName,
1531 final Object param0,
1532 final Object param1,
1533 final Object param2,
1534 final Object param3) {
1535 if (logger.isEnabledFor(level)) {
1536 forcedLog(logger, level,
1537 format(bundleName, key,
1538 toArray(param0, param1, param2, param3)));