001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache license, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the license for the specific language governing permissions and
015 * limitations under the license.
016 */
017package org.apache.logging.log4j.spi;
018
019import java.io.IOException;
020import java.io.ObjectInputStream;
021import java.io.Serializable;
022import java.lang.reflect.Field;
023
024import org.apache.logging.log4j.Level;
025import org.apache.logging.log4j.LogBuilder;
026import org.apache.logging.log4j.LoggingException;
027import org.apache.logging.log4j.Marker;
028import org.apache.logging.log4j.MarkerManager;
029import org.apache.logging.log4j.internal.DefaultLogBuilder;
030import org.apache.logging.log4j.message.DefaultFlowMessageFactory;
031import org.apache.logging.log4j.message.EntryMessage;
032import org.apache.logging.log4j.message.FlowMessageFactory;
033import org.apache.logging.log4j.message.Message;
034import org.apache.logging.log4j.message.MessageFactory;
035import org.apache.logging.log4j.message.MessageFactory2;
036import org.apache.logging.log4j.message.ParameterizedMessage;
037import org.apache.logging.log4j.message.ParameterizedMessageFactory;
038import org.apache.logging.log4j.message.ReusableMessageFactory;
039import org.apache.logging.log4j.message.SimpleMessage;
040import org.apache.logging.log4j.message.StringFormattedMessage;
041import org.apache.logging.log4j.status.StatusLogger;
042import org.apache.logging.log4j.util.Constants;
043import org.apache.logging.log4j.util.LambdaUtil;
044import org.apache.logging.log4j.util.LoaderUtil;
045import org.apache.logging.log4j.util.MessageSupplier;
046import org.apache.logging.log4j.util.PerformanceSensitive;
047import org.apache.logging.log4j.util.PropertiesUtil;
048import org.apache.logging.log4j.util.StackLocatorUtil;
049import org.apache.logging.log4j.util.Strings;
050import org.apache.logging.log4j.util.Supplier;
051
052/**
053 * Base implementation of a Logger. It is highly recommended that any Logger implementation extend this class.
054 */
055public abstract class AbstractLogger implements ExtendedLogger, LocationAwareLogger, Serializable {
056    // Implementation note: many methods in this class are tuned for performance. MODIFY WITH CARE!
057    // Specifically, try to keep the hot methods to 35 bytecodes or less:
058    // this is within the MaxInlineSize threshold on Java 7 and Java 8 Hotspot and makes these methods
059    // candidates for immediate inlining instead of waiting until they are designated "hot enough".
060
061    /**
062     * Marker for flow tracing.
063     */
064    public static final Marker FLOW_MARKER = MarkerManager.getMarker("FLOW");
065
066    /**
067     * Marker for method entry tracing.
068     */
069    public static final Marker ENTRY_MARKER = MarkerManager.getMarker("ENTER").setParents(FLOW_MARKER);
070
071    /**
072     * Marker for method exit tracing.
073     */
074    public static final Marker EXIT_MARKER = MarkerManager.getMarker("EXIT").setParents(FLOW_MARKER);
075
076    /**
077     * Marker for exception tracing.
078     */
079    public static final Marker EXCEPTION_MARKER = MarkerManager.getMarker("EXCEPTION");
080
081    /**
082     * Marker for throwing exceptions.
083     */
084    public static final Marker THROWING_MARKER = MarkerManager.getMarker("THROWING").setParents(EXCEPTION_MARKER);
085
086    /**
087     * Marker for catching exceptions.
088     */
089    public static final Marker CATCHING_MARKER = MarkerManager.getMarker("CATCHING").setParents(EXCEPTION_MARKER);
090
091    /**
092     * The default MessageFactory class.
093     */
094    public static final Class<? extends MessageFactory> DEFAULT_MESSAGE_FACTORY_CLASS =
095            createClassForProperty("log4j2.messageFactory", ReusableMessageFactory.class,
096                    ParameterizedMessageFactory.class);
097
098    /**
099     * The default FlowMessageFactory class.
100     */
101    public static final Class<? extends FlowMessageFactory> DEFAULT_FLOW_MESSAGE_FACTORY_CLASS =
102            createFlowClassForProperty("log4j2.flowMessageFactory", DefaultFlowMessageFactory.class);
103
104    private static final long serialVersionUID = 2L;
105
106    private static final String FQCN = AbstractLogger.class.getName();
107    private static final String THROWING = "Throwing";
108    private static final String CATCHING = "Catching";
109
110    protected final String name;
111    private final MessageFactory2 messageFactory;
112    private final FlowMessageFactory flowMessageFactory;
113    private static final ThreadLocal<int[]> recursionDepthHolder = new ThreadLocal<>(); // LOG4J2-1518, LOG4J2-2031
114    protected final transient ThreadLocal<DefaultLogBuilder> logBuilder;
115
116    /**
117     * Creates a new logger named after this class (or subclass).
118     */
119    public AbstractLogger() {
120        this.name = getClass().getName();
121        this.messageFactory = createDefaultMessageFactory();
122        this.flowMessageFactory = createDefaultFlowMessageFactory();
123        this.logBuilder = new LocalLogBuilder(this);
124    }
125
126    /**
127     * Creates a new named logger.
128     *
129     * @param name the logger name
130     */
131    public AbstractLogger(final String name) {
132        this(name, createDefaultMessageFactory());
133    }
134
135    /**
136     * Creates a new named logger with a particular {@link MessageFactory}.
137     *
138     * @param name the logger name
139     * @param messageFactory the message factory, if null then use the default message factory.
140     */
141    public AbstractLogger(final String name, final MessageFactory messageFactory) {
142        this.name = name;
143        this.messageFactory = messageFactory == null ? createDefaultMessageFactory() : narrow(messageFactory);
144        this.flowMessageFactory = createDefaultFlowMessageFactory();
145        this.logBuilder = new LocalLogBuilder(this);
146    }
147
148    /**
149     * Checks that the message factory a logger was created with is the same as the given messageFactory. If they are
150     * different log a warning to the {@linkplain StatusLogger}. A null MessageFactory translates to the default
151     * MessageFactory {@link #DEFAULT_MESSAGE_FACTORY_CLASS}.
152     *
153     * @param logger The logger to check
154     * @param messageFactory The message factory to check.
155     */
156    public static void checkMessageFactory(final ExtendedLogger logger, final MessageFactory messageFactory) {
157        final String name = logger.getName();
158        final MessageFactory loggerMessageFactory = logger.getMessageFactory();
159        if (messageFactory != null && !loggerMessageFactory.equals(messageFactory)) {
160            StatusLogger.getLogger().warn(
161                    "The Logger {} was created with the message factory {} and is now requested with the "
162                            + "message factory {}, which may create log events with unexpected formatting.", name,
163                    loggerMessageFactory, messageFactory);
164        } else if (messageFactory == null && !loggerMessageFactory.getClass().equals(DEFAULT_MESSAGE_FACTORY_CLASS)) {
165            StatusLogger
166                    .getLogger()
167                    .warn("The Logger {} was created with the message factory {} and is now requested with a null "
168                            + "message factory (defaults to {}), which may create log events with unexpected "
169                            + "formatting.",
170                            name, loggerMessageFactory, DEFAULT_MESSAGE_FACTORY_CLASS.getName());
171        }
172    }
173
174    @Override
175    public void catching(final Level level, final Throwable throwable) {
176        catching(FQCN, level, throwable);
177    }
178
179    /**
180     * Logs a Throwable that has been caught with location information.
181     *
182     * @param fqcn The fully qualified class name of the <b>caller</b>.
183     * @param level The logging level.
184     * @param throwable The Throwable.
185     */
186    protected void catching(final String fqcn, final Level level, final Throwable throwable) {
187        if (isEnabled(level, CATCHING_MARKER, (Object) null, null)) {
188            logMessageSafely(fqcn, level, CATCHING_MARKER, catchingMsg(throwable), throwable);
189        }
190    }
191
192    @Override
193    public void catching(final Throwable throwable) {
194        if (isEnabled(Level.ERROR, CATCHING_MARKER, (Object) null, null)) {
195            logMessageSafely(FQCN, Level.ERROR, CATCHING_MARKER, catchingMsg(throwable), throwable);
196        }
197    }
198
199    protected Message catchingMsg(final Throwable throwable) {
200        return messageFactory.newMessage(CATCHING);
201    }
202
203    private static Class<? extends MessageFactory> createClassForProperty(final String property,
204            final Class<ReusableMessageFactory> reusableParameterizedMessageFactoryClass,
205            final Class<ParameterizedMessageFactory> parameterizedMessageFactoryClass) {
206        try {
207            final String fallback = Constants.ENABLE_THREADLOCALS ? reusableParameterizedMessageFactoryClass.getName()
208                    : parameterizedMessageFactoryClass.getName();
209            final String clsName = PropertiesUtil.getProperties().getStringProperty(property, fallback);
210            return LoaderUtil.loadClass(clsName).asSubclass(MessageFactory.class);
211        } catch (final Throwable throwable) {
212            return parameterizedMessageFactoryClass;
213        }
214    }
215
216    private static Class<? extends FlowMessageFactory> createFlowClassForProperty(final String property,
217            final Class<DefaultFlowMessageFactory> defaultFlowMessageFactoryClass) {
218        try {
219            final String clsName = PropertiesUtil.getProperties().getStringProperty(property, defaultFlowMessageFactoryClass.getName());
220            return LoaderUtil.loadClass(clsName).asSubclass(FlowMessageFactory.class);
221        } catch (final Throwable throwable) {
222            return defaultFlowMessageFactoryClass;
223        }
224    }
225
226    private static MessageFactory2 createDefaultMessageFactory() {
227        try {
228            final MessageFactory result = DEFAULT_MESSAGE_FACTORY_CLASS.newInstance();
229            return narrow(result);
230        } catch (final InstantiationException | IllegalAccessException e) {
231            throw new IllegalStateException(e);
232        }
233    }
234
235    private static MessageFactory2 narrow(final MessageFactory result) {
236        if (result instanceof MessageFactory2) {
237            return (MessageFactory2) result;
238        }
239        return new MessageFactory2Adapter(result);
240    }
241
242    private static FlowMessageFactory createDefaultFlowMessageFactory() {
243        try {
244            return DEFAULT_FLOW_MESSAGE_FACTORY_CLASS.newInstance();
245        } catch (final InstantiationException | IllegalAccessException e) {
246            throw new IllegalStateException(e);
247        }
248    }
249
250    @Override
251    public void debug(final Marker marker, final CharSequence message) {
252        logIfEnabled(FQCN, Level.DEBUG, marker, message, null);
253    }
254
255    @Override
256    public void debug(final Marker marker, final CharSequence message, final Throwable throwable) {
257        logIfEnabled(FQCN, Level.DEBUG, marker, message, throwable);
258    }
259
260    @Override
261    public void debug(final Marker marker, final Message message) {
262        logIfEnabled(FQCN, Level.DEBUG, marker, message, message != null ? message.getThrowable() : null);
263    }
264
265    @Override
266    public void debug(final Marker marker, final Message message, final Throwable throwable) {
267        logIfEnabled(FQCN, Level.DEBUG, marker, message, throwable);
268    }
269
270    @Override
271    public void debug(final Marker marker, final Object message) {
272        logIfEnabled(FQCN, Level.DEBUG, marker, message, null);
273    }
274
275    @Override
276    public void debug(final Marker marker, final Object message, final Throwable throwable) {
277        logIfEnabled(FQCN, Level.DEBUG, marker, message, throwable);
278    }
279
280    @Override
281    public void debug(final Marker marker, final String message) {
282        logIfEnabled(FQCN, Level.DEBUG, marker, message, (Throwable) null);
283    }
284
285    @Override
286    public void debug(final Marker marker, final String message, final Object... params) {
287        logIfEnabled(FQCN, Level.DEBUG, marker, message, params);
288    }
289
290    @Override
291    public void debug(final Marker marker, final String message, final Throwable throwable) {
292        logIfEnabled(FQCN, Level.DEBUG, marker, message, throwable);
293    }
294
295    @Override
296    public void debug(final Message message) {
297        logIfEnabled(FQCN, Level.DEBUG, null, message, message != null ? message.getThrowable() : null);
298    }
299
300    @Override
301    public void debug(final Message message, final Throwable throwable) {
302        logIfEnabled(FQCN, Level.DEBUG, null, message, throwable);
303    }
304
305    @Override
306    public void debug(final CharSequence message) {
307        logIfEnabled(FQCN, Level.DEBUG, null, message, null);
308    }
309
310    @Override
311    public void debug(final CharSequence message, final Throwable throwable) {
312        logIfEnabled(FQCN, Level.DEBUG, null, message, throwable);
313    }
314
315    @Override
316    public void debug(final Object message) {
317        logIfEnabled(FQCN, Level.DEBUG, null, message, null);
318    }
319
320    @Override
321    public void debug(final Object message, final Throwable throwable) {
322        logIfEnabled(FQCN, Level.DEBUG, null, message, throwable);
323    }
324
325    @Override
326    public void debug(final String message) {
327        logIfEnabled(FQCN, Level.DEBUG, null, message, (Throwable) null);
328    }
329
330    @Override
331    public void debug(final String message, final Object... params) {
332        logIfEnabled(FQCN, Level.DEBUG, null, message, params);
333    }
334
335    @Override
336    public void debug(final String message, final Throwable throwable) {
337        logIfEnabled(FQCN, Level.DEBUG, null, message, throwable);
338    }
339
340    @Override
341    public void debug(final Supplier<?> messageSupplier) {
342        logIfEnabled(FQCN, Level.DEBUG, null, messageSupplier, (Throwable) null);
343    }
344
345    @Override
346    public void debug(final Supplier<?> messageSupplier, final Throwable throwable) {
347        logIfEnabled(FQCN, Level.DEBUG, null, messageSupplier, throwable);
348    }
349
350    @Override
351    public void debug(final Marker marker, final Supplier<?> messageSupplier) {
352        logIfEnabled(FQCN, Level.DEBUG, marker, messageSupplier, (Throwable) null);
353    }
354
355    @Override
356    public void debug(final Marker marker, final String message, final Supplier<?>... paramSuppliers) {
357        logIfEnabled(FQCN, Level.DEBUG, marker, message, paramSuppliers);
358    }
359
360    @Override
361    public void debug(final Marker marker, final Supplier<?> messageSupplier, final Throwable throwable) {
362        logIfEnabled(FQCN, Level.DEBUG, marker, messageSupplier, throwable);
363    }
364
365    @Override
366    public void debug(final String message, final Supplier<?>... paramSuppliers) {
367        logIfEnabled(FQCN, Level.DEBUG, null, message, paramSuppliers);
368    }
369
370    @Override
371    public void debug(final Marker marker, final MessageSupplier messageSupplier) {
372        logIfEnabled(FQCN, Level.DEBUG, marker, messageSupplier, (Throwable) null);
373    }
374
375    @Override
376    public void debug(final Marker marker, final MessageSupplier messageSupplier, final Throwable throwable) {
377        logIfEnabled(FQCN, Level.DEBUG, marker, messageSupplier, throwable);
378    }
379
380    @Override
381    public void debug(final MessageSupplier messageSupplier) {
382        logIfEnabled(FQCN, Level.DEBUG, null, messageSupplier, (Throwable) null);
383    }
384
385    @Override
386    public void debug(final MessageSupplier messageSupplier, final Throwable throwable) {
387        logIfEnabled(FQCN, Level.DEBUG, null, messageSupplier, throwable);
388    }
389
390    @Override
391    public void debug(final Marker marker, final String message, final Object p0) {
392        logIfEnabled(FQCN, Level.DEBUG, marker, message, p0);
393    }
394
395    @Override
396    public void debug(final Marker marker, final String message, final Object p0, final Object p1) {
397        logIfEnabled(FQCN, Level.DEBUG, marker, message, p0, p1);
398    }
399
400    @Override
401    public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2) {
402        logIfEnabled(FQCN, Level.DEBUG, marker, message, p0, p1, p2);
403    }
404
405    @Override
406    public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
407            final Object p3) {
408        logIfEnabled(FQCN, Level.DEBUG, marker, message, p0, p1, p2, p3);
409    }
410
411    @Override
412    public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
413            final Object p3, final Object p4) {
414        logIfEnabled(FQCN, Level.DEBUG, marker, message, p0, p1, p2, p3, p4);
415    }
416
417    @Override
418    public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
419            final Object p3, final Object p4, final Object p5) {
420        logIfEnabled(FQCN, Level.DEBUG, marker, message, p0, p1, p2, p3, p4, p5);
421    }
422
423    @Override
424    public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
425            final Object p3, final Object p4, final Object p5,
426            final Object p6) {
427        logIfEnabled(FQCN, Level.DEBUG, marker, message, p0, p1, p2, p3, p4, p5, p6);
428    }
429
430    @Override
431    public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
432            final Object p3, final Object p4, final Object p5,
433            final Object p6, final Object p7) {
434        logIfEnabled(FQCN, Level.DEBUG, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
435    }
436
437    @Override
438    public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
439            final Object p3, final Object p4, final Object p5,
440            final Object p6, final Object p7, final Object p8) {
441        logIfEnabled(FQCN, Level.DEBUG, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
442    }
443
444    @Override
445    public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
446            final Object p3, final Object p4, final Object p5,
447            final Object p6, final Object p7, final Object p8, final Object p9) {
448        logIfEnabled(FQCN, Level.DEBUG, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
449    }
450
451    @Override
452    public void debug(final String message, final Object p0) {
453        logIfEnabled(FQCN, Level.DEBUG, null, message, p0);
454    }
455
456    @Override
457    public void debug(final String message, final Object p0, final Object p1) {
458        logIfEnabled(FQCN, Level.DEBUG, null, message, p0, p1);
459    }
460
461    @Override
462    public void debug(final String message, final Object p0, final Object p1, final Object p2) {
463        logIfEnabled(FQCN, Level.DEBUG, null, message, p0, p1, p2);
464    }
465
466    @Override
467    public void debug(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
468        logIfEnabled(FQCN, Level.DEBUG, null, message, p0, p1, p2, p3);
469    }
470
471    @Override
472    public void debug(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
473            final Object p4) {
474        logIfEnabled(FQCN, Level.DEBUG, null, message, p0, p1, p2, p3, p4);
475    }
476
477    @Override
478    public void debug(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
479            final Object p4, final Object p5) {
480        logIfEnabled(FQCN, Level.DEBUG, null, message, p0, p1, p2, p3, p4, p5);
481    }
482
483    @Override
484    public void debug(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
485            final Object p4, final Object p5, final Object p6) {
486        logIfEnabled(FQCN, Level.DEBUG, null, message, p0, p1, p2, p3, p4, p5, p6);
487    }
488
489    @Override
490    public void debug(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
491            final Object p4, final Object p5, final Object p6,
492            final Object p7) {
493        logIfEnabled(FQCN, Level.DEBUG, null, message, p0, p1, p2, p3, p4, p5, p6, p7);
494    }
495
496    @Override
497    public void debug(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
498            final Object p4, final Object p5, final Object p6,
499            final Object p7, final Object p8) {
500        logIfEnabled(FQCN, Level.DEBUG, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
501    }
502
503    @Override
504    public void debug(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
505            final Object p4, final Object p5, final Object p6,
506            final Object p7, final Object p8, final Object p9) {
507        logIfEnabled(FQCN, Level.DEBUG, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
508    }
509
510    /**
511     * Logs entry to a method with location information.
512     *
513     * @param fqcn The fully qualified class name of the <b>caller</b>.
514     * @param format Format String for the parameters.
515     * @param paramSuppliers The Suppliers of the parameters.
516     */
517    protected EntryMessage enter(final String fqcn, final String format, final Supplier<?>... paramSuppliers) {
518        EntryMessage entryMsg = null;
519        if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
520            logMessageSafely(fqcn, Level.TRACE, ENTRY_MARKER, entryMsg = entryMsg(format, paramSuppliers), null);
521        }
522        return entryMsg;
523    }
524
525    /**
526     * Logs entry to a method with location information.
527     *
528     * @param fqcn The fully qualified class name of the <b>caller</b>.
529     * @param format The format String for the parameters.
530     * @param paramSuppliers The parameters to the method.
531     */
532    @Deprecated
533    protected EntryMessage enter(final String fqcn, final String format, final MessageSupplier... paramSuppliers) {
534        EntryMessage entryMsg = null;
535        if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
536            logMessageSafely(fqcn, Level.TRACE, ENTRY_MARKER, entryMsg = entryMsg(format, paramSuppliers), null);
537        }
538        return entryMsg;
539    }
540
541    /**
542     * Logs entry to a method with location information.
543     *
544     * @param fqcn The fully qualified class name of the <b>caller</b>.
545     * @param format The format String for the parameters.
546     * @param params The parameters to the method.
547     */
548    protected EntryMessage enter(final String fqcn, final String format, final Object... params) {
549        EntryMessage entryMsg = null;
550        if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
551            logMessageSafely(fqcn, Level.TRACE, ENTRY_MARKER, entryMsg = entryMsg(format, params), null);
552        }
553        return entryMsg;
554    }
555
556    /**
557     * Logs entry to a method with location information.
558     *
559     * @param fqcn The fully qualified class name of the <b>caller</b>.
560     * @param messageSupplier The Supplier of the Message.
561     */
562    @Deprecated
563    protected EntryMessage enter(final String fqcn, final MessageSupplier messageSupplier) {
564        EntryMessage message = null;
565        if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
566            logMessageSafely(fqcn, Level.TRACE, ENTRY_MARKER, message = flowMessageFactory.newEntryMessage(
567                    messageSupplier.get()), null);
568        }
569        return message;
570    }
571
572    /**
573     * Logs entry to a method with location information.
574     *
575     * @param fqcn
576     *            The fully qualified class name of the <b>caller</b>.
577     * @param message
578     *            the Message.
579     * @since 2.6
580     */
581    protected EntryMessage enter(final String fqcn, final Message message) {
582        EntryMessage flowMessage = null;
583        if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
584            logMessageSafely(fqcn, Level.TRACE, ENTRY_MARKER, flowMessage = flowMessageFactory.newEntryMessage(message),
585                    null);
586        }
587        return flowMessage;
588    }
589
590    @Deprecated
591    @Override
592    public void entry() {
593        entry(FQCN, (Object[]) null);
594    }
595
596    @Override
597    public void entry(final Object... params) {
598        entry(FQCN, params);
599    }
600
601    /**
602     * Logs entry to a method with location information.
603     *
604     * @param fqcn The fully qualified class name of the <b>caller</b>.
605     * @param params The parameters to the method.
606     */
607    protected void entry(final String fqcn, final Object... params) {
608        if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
609            if (params == null) {
610                logMessageSafely(fqcn, Level.TRACE, ENTRY_MARKER, entryMsg(null, (Supplier<?>[]) null), null);
611            } else {
612                logMessageSafely(fqcn, Level.TRACE, ENTRY_MARKER, entryMsg(null, params), null);
613            }
614        }
615    }
616
617    protected EntryMessage entryMsg(final String format, final Object... params) {
618        final int count = params == null ? 0 : params.length;
619        if (count == 0) {
620            if (Strings.isEmpty(format)) {
621                return flowMessageFactory.newEntryMessage(null);
622            }
623            return flowMessageFactory.newEntryMessage(new SimpleMessage(format));
624        }
625        if (format != null) {
626            return flowMessageFactory.newEntryMessage(new ParameterizedMessage(format, params));
627        }
628        final StringBuilder sb = new StringBuilder();
629        sb.append("params(");
630        for (int i = 0; i < count; i++) {
631            if (i > 0) {
632                sb.append(", ");
633            }
634            final Object parm = params[i];
635            sb.append(parm instanceof Message ? ((Message) parm).getFormattedMessage() : String.valueOf(parm));
636        }
637        sb.append(')');
638        return flowMessageFactory.newEntryMessage(new SimpleMessage(sb));
639    }
640
641    protected EntryMessage entryMsg(final String format, final MessageSupplier... paramSuppliers) {
642        final int count = paramSuppliers == null ? 0 : paramSuppliers.length;
643        final Object[] params = new Object[count];
644        for (int i = 0; i < count; i++) {
645            params[i] = paramSuppliers[i].get();
646            params[i] = params[i] != null ? ((Message) params[i]).getFormattedMessage() : null;
647        }
648        return entryMsg(format, params);
649    }
650
651    protected EntryMessage entryMsg(final String format, final Supplier<?>... paramSuppliers) {
652        final int count = paramSuppliers == null ? 0 : paramSuppliers.length;
653        final Object[] params = new Object[count];
654        for (int i = 0; i < count; i++) {
655            params[i] = paramSuppliers[i].get();
656            if (params[i] instanceof Message) {
657                params[i] = ((Message) params[i]).getFormattedMessage();
658            }
659        }
660        return entryMsg(format, params);
661    }
662
663    @Override
664    public void error(final Marker marker, final Message message) {
665        logIfEnabled(FQCN, Level.ERROR, marker, message, message != null ? message.getThrowable() : null);
666    }
667
668    @Override
669    public void error(final Marker marker, final Message message, final Throwable throwable) {
670        logIfEnabled(FQCN, Level.ERROR, marker, message, throwable);
671    }
672
673    @Override
674    public void error(final Marker marker, final CharSequence message) {
675        logIfEnabled(FQCN, Level.ERROR, marker, message, null);
676    }
677
678    @Override
679    public void error(final Marker marker, final CharSequence message, final Throwable throwable) {
680        logIfEnabled(FQCN, Level.ERROR, marker, message, throwable);
681    }
682
683    @Override
684    public void error(final Marker marker, final Object message) {
685        logIfEnabled(FQCN, Level.ERROR, marker, message, null);
686    }
687
688    @Override
689    public void error(final Marker marker, final Object message, final Throwable throwable) {
690        logIfEnabled(FQCN, Level.ERROR, marker, message, throwable);
691    }
692
693    @Override
694    public void error(final Marker marker, final String message) {
695        logIfEnabled(FQCN, Level.ERROR, marker, message, (Throwable) null);
696    }
697
698    @Override
699    public void error(final Marker marker, final String message, final Object... params) {
700        logIfEnabled(FQCN, Level.ERROR, marker, message, params);
701    }
702
703    @Override
704    public void error(final Marker marker, final String message, final Throwable throwable) {
705        logIfEnabled(FQCN, Level.ERROR, marker, message, throwable);
706    }
707
708    @Override
709    public void error(final Message message) {
710        logIfEnabled(FQCN, Level.ERROR, null, message, message != null ? message.getThrowable() : null);
711    }
712
713    @Override
714    public void error(final Message message, final Throwable throwable) {
715        logIfEnabled(FQCN, Level.ERROR, null, message, throwable);
716    }
717
718    @Override
719    public void error(final CharSequence message) {
720        logIfEnabled(FQCN, Level.ERROR, null, message, null);
721    }
722
723    @Override
724    public void error(final CharSequence message, final Throwable throwable) {
725        logIfEnabled(FQCN, Level.ERROR, null, message, throwable);
726    }
727
728    @Override
729    public void error(final Object message) {
730        logIfEnabled(FQCN, Level.ERROR, null, message, null);
731    }
732
733    @Override
734    public void error(final Object message, final Throwable throwable) {
735        logIfEnabled(FQCN, Level.ERROR, null, message, throwable);
736    }
737
738    @Override
739    public void error(final String message) {
740        logIfEnabled(FQCN, Level.ERROR, null, message, (Throwable) null);
741    }
742
743    @Override
744    public void error(final String message, final Object... params) {
745        logIfEnabled(FQCN, Level.ERROR, null, message, params);
746    }
747
748    @Override
749    public void error(final String message, final Throwable throwable) {
750        logIfEnabled(FQCN, Level.ERROR, null, message, throwable);
751    }
752
753    @Override
754    public void error(final Supplier<?> messageSupplier) {
755        logIfEnabled(FQCN, Level.ERROR, null, messageSupplier, (Throwable) null);
756    }
757
758    @Override
759    public void error(final Supplier<?> messageSupplier, final Throwable throwable) {
760        logIfEnabled(FQCN, Level.ERROR, null, messageSupplier, throwable);
761    }
762
763    @Override
764    public void error(final Marker marker, final Supplier<?> messageSupplier) {
765        logIfEnabled(FQCN, Level.ERROR, marker, messageSupplier, (Throwable) null);
766    }
767
768    @Override
769    public void error(final Marker marker, final String message, final Supplier<?>... paramSuppliers) {
770        logIfEnabled(FQCN, Level.ERROR, marker, message, paramSuppliers);
771    }
772
773    @Override
774    public void error(final Marker marker, final Supplier<?> messageSupplier, final Throwable throwable) {
775        logIfEnabled(FQCN, Level.ERROR, marker, messageSupplier, throwable);
776    }
777
778    @Override
779    public void error(final String message, final Supplier<?>... paramSuppliers) {
780        logIfEnabled(FQCN, Level.ERROR, null, message, paramSuppliers);
781    }
782
783    @Override
784    public void error(final Marker marker, final MessageSupplier messageSupplier) {
785        logIfEnabled(FQCN, Level.ERROR, marker, messageSupplier, (Throwable) null);
786    }
787
788    @Override
789    public void error(final Marker marker, final MessageSupplier messageSupplier, final Throwable throwable) {
790        logIfEnabled(FQCN, Level.ERROR, marker, messageSupplier, throwable);
791    }
792
793    @Override
794    public void error(final MessageSupplier messageSupplier) {
795        logIfEnabled(FQCN, Level.ERROR, null, messageSupplier, (Throwable) null);
796    }
797
798    @Override
799    public void error(final MessageSupplier messageSupplier, final Throwable throwable) {
800        logIfEnabled(FQCN, Level.ERROR, null, messageSupplier, throwable);
801    }
802
803    @Override
804    public void error(final Marker marker, final String message, final Object p0) {
805        logIfEnabled(FQCN, Level.ERROR, marker, message, p0);
806    }
807
808    @Override
809    public void error(final Marker marker, final String message, final Object p0, final Object p1) {
810        logIfEnabled(FQCN, Level.ERROR, marker, message, p0, p1);
811    }
812
813    @Override
814    public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2) {
815        logIfEnabled(FQCN, Level.ERROR, marker, message, p0, p1, p2);
816    }
817
818    @Override
819    public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
820            final Object p3) {
821        logIfEnabled(FQCN, Level.ERROR, marker, message, p0, p1, p2, p3);
822    }
823
824    @Override
825    public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
826            final Object p3, final Object p4) {
827        logIfEnabled(FQCN, Level.ERROR, marker, message, p0, p1, p2, p3, p4);
828    }
829
830    @Override
831    public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
832            final Object p3, final Object p4, final Object p5) {
833        logIfEnabled(FQCN, Level.ERROR, marker, message, p0, p1, p2, p3, p4, p5);
834    }
835
836    @Override
837    public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
838            final Object p3, final Object p4, final Object p5,
839            final Object p6) {
840        logIfEnabled(FQCN, Level.ERROR, marker, message, p0, p1, p2, p3, p4, p5, p6);
841    }
842
843    @Override
844    public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
845            final Object p3, final Object p4, final Object p5,
846            final Object p6, final Object p7) {
847        logIfEnabled(FQCN, Level.ERROR, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
848    }
849
850    @Override
851    public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
852            final Object p3, final Object p4, final Object p5,
853            final Object p6, final Object p7, final Object p8) {
854        logIfEnabled(FQCN, Level.ERROR, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
855    }
856
857    @Override
858    public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
859            final Object p3, final Object p4, final Object p5,
860            final Object p6, final Object p7, final Object p8, final Object p9) {
861        logIfEnabled(FQCN, Level.ERROR, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
862    }
863
864    @Override
865    public void error(final String message, final Object p0) {
866        logIfEnabled(FQCN, Level.ERROR, null, message, p0);
867    }
868
869    @Override
870    public void error(final String message, final Object p0, final Object p1) {
871        logIfEnabled(FQCN, Level.ERROR, null, message, p0, p1);
872    }
873
874    @Override
875    public void error(final String message, final Object p0, final Object p1, final Object p2) {
876        logIfEnabled(FQCN, Level.ERROR, null, message, p0, p1, p2);
877    }
878
879    @Override
880    public void error(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
881        logIfEnabled(FQCN, Level.ERROR, null, message, p0, p1, p2, p3);
882    }
883
884    @Override
885    public void error(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
886            final Object p4) {
887        logIfEnabled(FQCN, Level.ERROR, null, message, p0, p1, p2, p3, p4);
888    }
889
890    @Override
891    public void error(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
892            final Object p4, final Object p5) {
893        logIfEnabled(FQCN, Level.ERROR, null, message, p0, p1, p2, p3, p4, p5);
894    }
895
896    @Override
897    public void error(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
898            final Object p4, final Object p5, final Object p6) {
899        logIfEnabled(FQCN, Level.ERROR, null, message, p0, p1, p2, p3, p4, p5, p6);
900    }
901
902    @Override
903    public void error(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
904            final Object p4, final Object p5, final Object p6, final Object p7) {
905        logIfEnabled(FQCN, Level.ERROR, null, message, p0, p1, p2, p3, p4, p5, p6, p7);
906    }
907
908    @Override
909    public void error(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
910            final Object p4, final Object p5, final Object p6, final Object p7, final Object p8) {
911        logIfEnabled(FQCN, Level.ERROR, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
912    }
913
914    @Override
915    public void error(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
916            final Object p4, final Object p5, final Object p6, final Object p7, final Object p8, final Object p9) {
917        logIfEnabled(FQCN, Level.ERROR, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
918    }
919
920    @Deprecated
921    @Override
922    public void exit() {
923        exit(FQCN, (Object) null);
924    }
925
926    @Deprecated
927    @Override
928    public <R> R exit(final R result) {
929        return exit(FQCN, result);
930    }
931
932    /**
933     * Logs exiting from a method with the result and location information.
934     *
935     * @param fqcn The fully qualified class name of the <b>caller</b>.
936     * @param <R> The type of the parameter and object being returned.
937     * @param result The result being returned from the method call.
938     * @return the return value passed to this method.
939     */
940    protected <R> R exit(final String fqcn, final R result) {
941        if (isEnabled(Level.TRACE, EXIT_MARKER, (CharSequence) null, null)) {
942            logMessageSafely(fqcn, Level.TRACE, EXIT_MARKER, exitMsg(null, result), null);
943        }
944        return result;
945    }
946
947    /**
948     * Logs exiting from a method with the result and location information.
949     *
950     * @param fqcn The fully qualified class name of the <b>caller</b>.
951     * @param <R> The type of the parameter and object being returned.
952     * @param result The result being returned from the method call.
953     * @return the return value passed to this method.
954     */
955    protected <R> R exit(final String fqcn, final String format, final R result) {
956        if (isEnabled(Level.TRACE, EXIT_MARKER, (CharSequence) null, null)) {
957            logMessageSafely(fqcn, Level.TRACE, EXIT_MARKER, exitMsg(format, result), null);
958        }
959        return result;
960    }
961
962    protected Message exitMsg(final String format, final Object result) {
963        if (result == null) {
964            if (format == null) {
965                return messageFactory.newMessage("Exit");
966            }
967            return messageFactory.newMessage("Exit: " + format);
968        }
969        if (format == null) {
970            return messageFactory.newMessage("Exit with(" + result + ')');
971        }
972        return messageFactory.newMessage("Exit: " + format, result);
973
974    }
975
976    @Override
977    public void fatal(final Marker marker, final Message message) {
978        logIfEnabled(FQCN, Level.FATAL, marker, message, message != null ? message.getThrowable() : null);
979    }
980
981    @Override
982    public void fatal(final Marker marker, final Message message, final Throwable throwable) {
983        logIfEnabled(FQCN, Level.FATAL, marker, message, throwable);
984    }
985
986    @Override
987    public void fatal(final Marker marker, final CharSequence message) {
988        logIfEnabled(FQCN, Level.FATAL, marker, message, null);
989    }
990
991    @Override
992    public void fatal(final Marker marker, final CharSequence message, final Throwable throwable) {
993        logIfEnabled(FQCN, Level.FATAL, marker, message, throwable);
994    }
995
996    @Override
997    public void fatal(final Marker marker, final Object message) {
998        logIfEnabled(FQCN, Level.FATAL, marker, message, null);
999    }
1000
1001    @Override
1002    public void fatal(final Marker marker, final Object message, final Throwable throwable) {
1003        logIfEnabled(FQCN, Level.FATAL, marker, message, throwable);
1004    }
1005
1006    @Override
1007    public void fatal(final Marker marker, final String message) {
1008        logIfEnabled(FQCN, Level.FATAL, marker, message, (Throwable) null);
1009    }
1010
1011    @Override
1012    public void fatal(final Marker marker, final String message, final Object... params) {
1013        logIfEnabled(FQCN, Level.FATAL, marker, message, params);
1014    }
1015
1016    @Override
1017    public void fatal(final Marker marker, final String message, final Throwable throwable) {
1018        logIfEnabled(FQCN, Level.FATAL, marker, message, throwable);
1019    }
1020
1021    @Override
1022    public void fatal(final Message message) {
1023        logIfEnabled(FQCN, Level.FATAL, null, message, message != null ? message.getThrowable() : null);
1024    }
1025
1026    @Override
1027    public void fatal(final Message message, final Throwable throwable) {
1028        logIfEnabled(FQCN, Level.FATAL, null, message, throwable);
1029    }
1030
1031    @Override
1032    public void fatal(final CharSequence message) {
1033        logIfEnabled(FQCN, Level.FATAL, null, message, null);
1034    }
1035
1036    @Override
1037    public void fatal(final CharSequence message, final Throwable throwable) {
1038        logIfEnabled(FQCN, Level.FATAL, null, message, throwable);
1039    }
1040
1041    @Override
1042    public void fatal(final Object message) {
1043        logIfEnabled(FQCN, Level.FATAL, null, message, null);
1044    }
1045
1046    @Override
1047    public void fatal(final Object message, final Throwable throwable) {
1048        logIfEnabled(FQCN, Level.FATAL, null, message, throwable);
1049    }
1050
1051    @Override
1052    public void fatal(final String message) {
1053        logIfEnabled(FQCN, Level.FATAL, null, message, (Throwable) null);
1054    }
1055
1056    @Override
1057    public void fatal(final String message, final Object... params) {
1058        logIfEnabled(FQCN, Level.FATAL, null, message, params);
1059    }
1060
1061    @Override
1062    public void fatal(final String message, final Throwable throwable) {
1063        logIfEnabled(FQCN, Level.FATAL, null, message, throwable);
1064    }
1065
1066    @Override
1067    public void fatal(final Supplier<?> messageSupplier) {
1068        logIfEnabled(FQCN, Level.FATAL, null, messageSupplier, (Throwable) null);
1069    }
1070
1071    @Override
1072    public void fatal(final Supplier<?> messageSupplier, final Throwable throwable) {
1073        logIfEnabled(FQCN, Level.FATAL, null, messageSupplier, throwable);
1074    }
1075
1076    @Override
1077    public void fatal(final Marker marker, final Supplier<?> messageSupplier) {
1078        logIfEnabled(FQCN, Level.FATAL, marker, messageSupplier, (Throwable) null);
1079    }
1080
1081    @Override
1082    public void fatal(final Marker marker, final String message, final Supplier<?>... paramSuppliers) {
1083        logIfEnabled(FQCN, Level.FATAL, marker, message, paramSuppliers);
1084    }
1085
1086    @Override
1087    public void fatal(final Marker marker, final Supplier<?> messageSupplier, final Throwable throwable) {
1088        logIfEnabled(FQCN, Level.FATAL, marker, messageSupplier, throwable);
1089    }
1090
1091    @Override
1092    public void fatal(final String message, final Supplier<?>... paramSuppliers) {
1093        logIfEnabled(FQCN, Level.FATAL, null, message, paramSuppliers);
1094    }
1095
1096    @Override
1097    public void fatal(final Marker marker, final MessageSupplier messageSupplier) {
1098        logIfEnabled(FQCN, Level.FATAL, marker, messageSupplier, (Throwable) null);
1099    }
1100
1101    @Override
1102    public void fatal(final Marker marker, final MessageSupplier messageSupplier, final Throwable throwable) {
1103        logIfEnabled(FQCN, Level.FATAL, marker, messageSupplier, throwable);
1104    }
1105
1106    @Override
1107    public void fatal(final MessageSupplier messageSupplier) {
1108        logIfEnabled(FQCN, Level.FATAL, null, messageSupplier, (Throwable) null);
1109    }
1110
1111    @Override
1112    public void fatal(final MessageSupplier messageSupplier, final Throwable throwable) {
1113        logIfEnabled(FQCN, Level.FATAL, null, messageSupplier, throwable);
1114    }
1115
1116    @Override
1117    public void fatal(final Marker marker, final String message, final Object p0) {
1118        logIfEnabled(FQCN, Level.FATAL, marker, message, p0);
1119    }
1120
1121    @Override
1122    public void fatal(final Marker marker, final String message, final Object p0, final Object p1) {
1123        logIfEnabled(FQCN, Level.FATAL, marker, message, p0, p1);
1124    }
1125
1126    @Override
1127    public void fatal(final Marker marker, final String message, final Object p0, final Object p1, final Object p2) {
1128        logIfEnabled(FQCN, Level.FATAL, marker, message, p0, p1, p2);
1129    }
1130
1131    @Override
1132    public void fatal(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1133            final Object p3) {
1134        logIfEnabled(FQCN, Level.FATAL, marker, message, p0, p1, p2, p3);
1135    }
1136
1137    @Override
1138    public void fatal(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1139            final Object p3, final Object p4) {
1140        logIfEnabled(FQCN, Level.FATAL, marker, message, p0, p1, p2, p3, p4);
1141    }
1142
1143    @Override
1144    public void fatal(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1145            final Object p3, final Object p4, final Object p5) {
1146        logIfEnabled(FQCN, Level.FATAL, marker, message, p0, p1, p2, p3, p4, p5);
1147    }
1148
1149    @Override
1150    public void fatal(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1151            final Object p3, final Object p4, final Object p5, final Object p6) {
1152        logIfEnabled(FQCN, Level.FATAL, marker, message, p0, p1, p2, p3, p4, p5, p6);
1153    }
1154
1155    @Override
1156    public void fatal(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1157            final Object p3, final Object p4, final Object p5, final Object p6, final Object p7) {
1158        logIfEnabled(FQCN, Level.FATAL, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
1159    }
1160
1161    @Override
1162    public void fatal(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1163            final Object p3, final Object p4, final Object p5,
1164            final Object p6, final Object p7, final Object p8) {
1165        logIfEnabled(FQCN, Level.FATAL, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
1166    }
1167
1168    @Override
1169    public void fatal(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1170            final Object p3, final Object p4, final Object p5,
1171            final Object p6, final Object p7, final Object p8, final Object p9) {
1172        logIfEnabled(FQCN, Level.FATAL, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1173    }
1174
1175    @Override
1176    public void fatal(final String message, final Object p0) {
1177        logIfEnabled(FQCN, Level.FATAL, null, message, p0);
1178    }
1179
1180    @Override
1181    public void fatal(final String message, final Object p0, final Object p1) {
1182        logIfEnabled(FQCN, Level.FATAL, null, message, p0, p1);
1183    }
1184
1185    @Override
1186    public void fatal(final String message, final Object p0, final Object p1, final Object p2) {
1187        logIfEnabled(FQCN, Level.FATAL, null, message, p0, p1, p2);
1188    }
1189
1190    @Override
1191    public void fatal(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
1192        logIfEnabled(FQCN, Level.FATAL, null, message, p0, p1, p2, p3);
1193    }
1194
1195    @Override
1196    public void fatal(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1197            final Object p4) {
1198        logIfEnabled(FQCN, Level.FATAL, null, message, p0, p1, p2, p3, p4);
1199    }
1200
1201    @Override
1202    public void fatal(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1203            final Object p4, final Object p5) {
1204        logIfEnabled(FQCN, Level.FATAL, null, message, p0, p1, p2, p3, p4, p5);
1205    }
1206
1207    @Override
1208    public void fatal(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1209            final Object p4, final Object p5, final Object p6) {
1210        logIfEnabled(FQCN, Level.FATAL, null, message, p0, p1, p2, p3, p4, p5, p6);
1211    }
1212
1213    @Override
1214    public void fatal(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1215            final Object p4, final Object p5, final Object p6, final Object p7) {
1216        logIfEnabled(FQCN, Level.FATAL, null, message, p0, p1, p2, p3, p4, p5, p6, p7);
1217    }
1218
1219    @Override
1220    public void fatal(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1221            final Object p4, final Object p5, final Object p6, final Object p7, final Object p8) {
1222        logIfEnabled(FQCN, Level.FATAL, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
1223    }
1224
1225    @Override
1226    public void fatal(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1227            final Object p4, final Object p5, final Object p6,
1228            final Object p7, final Object p8, final Object p9) {
1229        logIfEnabled(FQCN, Level.FATAL, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1230    }
1231
1232    @SuppressWarnings("unchecked")
1233    @Override
1234    public <MF extends MessageFactory> MF getMessageFactory() {
1235        return (MF) messageFactory;
1236    }
1237
1238    @Override
1239    public String getName() {
1240        return name;
1241    }
1242
1243    @Override
1244    public void info(final Marker marker, final Message message) {
1245        logIfEnabled(FQCN, Level.INFO, marker, message, message != null ? message.getThrowable() : null);
1246    }
1247
1248    @Override
1249    public void info(final Marker marker, final Message message, final Throwable throwable) {
1250        logIfEnabled(FQCN, Level.INFO, marker, message, throwable);
1251    }
1252
1253    @Override
1254    public void info(final Marker marker, final CharSequence message) {
1255        logIfEnabled(FQCN, Level.INFO, marker, message, null);
1256    }
1257
1258    @Override
1259    public void info(final Marker marker, final CharSequence message, final Throwable throwable) {
1260        logIfEnabled(FQCN, Level.INFO, marker, message, throwable);
1261    }
1262
1263    @Override
1264    public void info(final Marker marker, final Object message) {
1265        logIfEnabled(FQCN, Level.INFO, marker, message, null);
1266    }
1267
1268    @Override
1269    public void info(final Marker marker, final Object message, final Throwable throwable) {
1270        logIfEnabled(FQCN, Level.INFO, marker, message, throwable);
1271    }
1272
1273    @Override
1274    public void info(final Marker marker, final String message) {
1275        logIfEnabled(FQCN, Level.INFO, marker, message, (Throwable) null);
1276    }
1277
1278    @Override
1279    public void info(final Marker marker, final String message, final Object... params) {
1280        logIfEnabled(FQCN, Level.INFO, marker, message, params);
1281    }
1282
1283    @Override
1284    public void info(final Marker marker, final String message, final Throwable throwable) {
1285        logIfEnabled(FQCN, Level.INFO, marker, message, throwable);
1286    }
1287
1288    @Override
1289    public void info(final Message message) {
1290        logIfEnabled(FQCN, Level.INFO, null, message, message != null ? message.getThrowable() : null);
1291    }
1292
1293    @Override
1294    public void info(final Message message, final Throwable throwable) {
1295        logIfEnabled(FQCN, Level.INFO, null, message, throwable);
1296    }
1297
1298    @Override
1299    public void info(final CharSequence message) {
1300        logIfEnabled(FQCN, Level.INFO, null, message, null);
1301    }
1302
1303    @Override
1304    public void info(final CharSequence message, final Throwable throwable) {
1305        logIfEnabled(FQCN, Level.INFO, null, message, throwable);
1306    }
1307
1308    @Override
1309    public void info(final Object message) {
1310        logIfEnabled(FQCN, Level.INFO, null, message, null);
1311    }
1312
1313    @Override
1314    public void info(final Object message, final Throwable throwable) {
1315        logIfEnabled(FQCN, Level.INFO, null, message, throwable);
1316    }
1317
1318    @Override
1319    public void info(final String message) {
1320        logIfEnabled(FQCN, Level.INFO, null, message, (Throwable) null);
1321    }
1322
1323    @Override
1324    public void info(final String message, final Object... params) {
1325        logIfEnabled(FQCN, Level.INFO, null, message, params);
1326    }
1327
1328    @Override
1329    public void info(final String message, final Throwable throwable) {
1330        logIfEnabled(FQCN, Level.INFO, null, message, throwable);
1331    }
1332
1333    @Override
1334    public void info(final Supplier<?> messageSupplier) {
1335        logIfEnabled(FQCN, Level.INFO, null, messageSupplier, (Throwable) null);
1336    }
1337
1338    @Override
1339    public void info(final Supplier<?> messageSupplier, final Throwable throwable) {
1340        logIfEnabled(FQCN, Level.INFO, null, messageSupplier, throwable);
1341    }
1342
1343    @Override
1344    public void info(final Marker marker, final Supplier<?> messageSupplier) {
1345        logIfEnabled(FQCN, Level.INFO, marker, messageSupplier, (Throwable) null);
1346    }
1347
1348    @Override
1349    public void info(final Marker marker, final String message, final Supplier<?>... paramSuppliers) {
1350        logIfEnabled(FQCN, Level.INFO, marker, message, paramSuppliers);
1351    }
1352
1353    @Override
1354    public void info(final Marker marker, final Supplier<?> messageSupplier, final Throwable throwable) {
1355        logIfEnabled(FQCN, Level.INFO, marker, messageSupplier, throwable);
1356    }
1357
1358    @Override
1359    public void info(final String message, final Supplier<?>... paramSuppliers) {
1360        logIfEnabled(FQCN, Level.INFO, null, message, paramSuppliers);
1361    }
1362
1363    @Override
1364    public void info(final Marker marker, final MessageSupplier messageSupplier) {
1365        logIfEnabled(FQCN, Level.INFO, marker, messageSupplier, (Throwable) null);
1366    }
1367
1368    @Override
1369    public void info(final Marker marker, final MessageSupplier messageSupplier, final Throwable throwable) {
1370        logIfEnabled(FQCN, Level.INFO, marker, messageSupplier, throwable);
1371    }
1372
1373    @Override
1374    public void info(final MessageSupplier messageSupplier) {
1375        logIfEnabled(FQCN, Level.INFO, null, messageSupplier, (Throwable) null);
1376    }
1377
1378    @Override
1379    public void info(final MessageSupplier messageSupplier, final Throwable throwable) {
1380        logIfEnabled(FQCN, Level.INFO, null, messageSupplier, throwable);
1381    }
1382
1383    @Override
1384    public void info(final Marker marker, final String message, final Object p0) {
1385        logIfEnabled(FQCN, Level.INFO, marker, message, p0);
1386    }
1387
1388    @Override
1389    public void info(final Marker marker, final String message, final Object p0, final Object p1) {
1390        logIfEnabled(FQCN, Level.INFO, marker, message, p0, p1);
1391    }
1392
1393    @Override
1394    public void info(final Marker marker, final String message, final Object p0, final Object p1, final Object p2) {
1395        logIfEnabled(FQCN, Level.INFO, marker, message, p0, p1, p2);
1396    }
1397
1398    @Override
1399    public void info(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1400            final Object p3) {
1401        logIfEnabled(FQCN, Level.INFO, marker, message, p0, p1, p2, p3);
1402    }
1403
1404    @Override
1405    public void info(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1406            final Object p3, final Object p4) {
1407        logIfEnabled(FQCN, Level.INFO, marker, message, p0, p1, p2, p3, p4);
1408    }
1409
1410    @Override
1411    public void info(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1412            final Object p3, final Object p4, final Object p5) {
1413        logIfEnabled(FQCN, Level.INFO, marker, message, p0, p1, p2, p3, p4, p5);
1414    }
1415
1416    @Override
1417    public void info(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1418            final Object p3, final Object p4, final Object p5, final Object p6) {
1419        logIfEnabled(FQCN, Level.INFO, marker, message, p0, p1, p2, p3, p4, p5, p6);
1420    }
1421
1422    @Override
1423    public void info(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1424            final Object p3, final Object p4, final Object p5, final Object p6, final Object p7) {
1425        logIfEnabled(FQCN, Level.INFO, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
1426    }
1427
1428    @Override
1429    public void info(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1430            final Object p3, final Object p4, final Object p5,
1431            final Object p6, final Object p7, final Object p8) {
1432        logIfEnabled(FQCN, Level.INFO, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
1433    }
1434
1435    @Override
1436    public void info(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
1437            final Object p3, final Object p4, final Object p5,
1438            final Object p6, final Object p7, final Object p8, final Object p9) {
1439        logIfEnabled(FQCN, Level.INFO, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1440    }
1441
1442    @Override
1443    public void info(final String message, final Object p0) {
1444        logIfEnabled(FQCN, Level.INFO, null, message, p0);
1445    }
1446
1447    @Override
1448    public void info(final String message, final Object p0, final Object p1) {
1449        logIfEnabled(FQCN, Level.INFO, null, message, p0, p1);
1450    }
1451
1452    @Override
1453    public void info(final String message, final Object p0, final Object p1, final Object p2) {
1454        logIfEnabled(FQCN, Level.INFO, null, message, p0, p1, p2);
1455    }
1456
1457    @Override
1458    public void info(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
1459        logIfEnabled(FQCN, Level.INFO, null, message, p0, p1, p2, p3);
1460    }
1461
1462    @Override
1463    public void info(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1464            final Object p4) {
1465        logIfEnabled(FQCN, Level.INFO, null, message, p0, p1, p2, p3, p4);
1466    }
1467
1468    @Override
1469    public void info(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1470            final Object p4, final Object p5) {
1471        logIfEnabled(FQCN, Level.INFO, null, message, p0, p1, p2, p3, p4, p5);
1472    }
1473
1474    @Override
1475    public void info(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1476            final Object p4, final Object p5, final Object p6) {
1477        logIfEnabled(FQCN, Level.INFO, null, message, p0, p1, p2, p3, p4, p5, p6);
1478    }
1479
1480    @Override
1481    public void info(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1482            final Object p4, final Object p5, final Object p6,
1483            final Object p7) {
1484        logIfEnabled(FQCN, Level.INFO, null, message, p0, p1, p2, p3, p4, p5, p6, p7);
1485    }
1486
1487    @Override
1488    public void info(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1489            final Object p4, final Object p5, final Object p6,
1490            final Object p7, final Object p8) {
1491        logIfEnabled(FQCN, Level.INFO, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
1492    }
1493
1494    @Override
1495    public void info(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1496            final Object p4, final Object p5, final Object p6,
1497            final Object p7, final Object p8, final Object p9) {
1498        logIfEnabled(FQCN, Level.INFO, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1499    }
1500
1501    @Override
1502    public boolean isDebugEnabled() {
1503        return isEnabled(Level.DEBUG, null, null);
1504    }
1505
1506    @Override
1507    public boolean isDebugEnabled(final Marker marker) {
1508        return isEnabled(Level.DEBUG, marker, (Object) null, null);
1509    }
1510
1511    @Override
1512    public boolean isEnabled(final Level level) {
1513        return isEnabled(level, null, (Object) null, null);
1514    }
1515
1516    @Override
1517    public boolean isEnabled(final Level level, final Marker marker) {
1518        return isEnabled(level, marker, (Object) null, null);
1519    }
1520
1521    @Override
1522    public boolean isErrorEnabled() {
1523        return isEnabled(Level.ERROR, null, (Object) null, null);
1524    }
1525
1526    @Override
1527    public boolean isErrorEnabled(final Marker marker) {
1528        return isEnabled(Level.ERROR, marker, (Object) null, null);
1529    }
1530
1531    @Override
1532    public boolean isFatalEnabled() {
1533        return isEnabled(Level.FATAL, null, (Object) null, null);
1534    }
1535
1536    @Override
1537    public boolean isFatalEnabled(final Marker marker) {
1538        return isEnabled(Level.FATAL, marker, (Object) null, null);
1539    }
1540
1541    @Override
1542    public boolean isInfoEnabled() {
1543        return isEnabled(Level.INFO, null, (Object) null, null);
1544    }
1545
1546    @Override
1547    public boolean isInfoEnabled(final Marker marker) {
1548        return isEnabled(Level.INFO, marker, (Object) null, null);
1549    }
1550
1551    @Override
1552    public boolean isTraceEnabled() {
1553        return isEnabled(Level.TRACE, null, (Object) null, null);
1554    }
1555
1556    @Override
1557    public boolean isTraceEnabled(final Marker marker) {
1558        return isEnabled(Level.TRACE, marker, (Object) null, null);
1559    }
1560
1561    @Override
1562    public boolean isWarnEnabled() {
1563        return isEnabled(Level.WARN, null, (Object) null, null);
1564    }
1565
1566    @Override
1567    public boolean isWarnEnabled(final Marker marker) {
1568        return isEnabled(Level.WARN, marker, (Object) null, null);
1569    }
1570
1571    @Override
1572    public void log(final Level level, final Marker marker, final Message message) {
1573        logIfEnabled(FQCN, level, marker, message, message != null ? message.getThrowable() : null);
1574    }
1575
1576    @Override
1577    public void log(final Level level, final Marker marker, final Message message, final Throwable throwable) {
1578        logIfEnabled(FQCN, level, marker, message, throwable);
1579    }
1580
1581    @Override
1582    public void log(final Level level, final Marker marker, final CharSequence message) {
1583        logIfEnabled(FQCN, level, marker, message, (Throwable) null);
1584    }
1585
1586    @Override
1587    public void log(final Level level, final Marker marker, final CharSequence message, final Throwable throwable) {
1588        if (isEnabled(level, marker, message, throwable)) {
1589            logMessage(FQCN, level, marker, message, throwable);
1590        }
1591    }
1592
1593    @Override
1594    public void log(final Level level, final Marker marker, final Object message) {
1595        logIfEnabled(FQCN, level, marker, message, (Throwable) null);
1596    }
1597
1598    @Override
1599    public void log(final Level level, final Marker marker, final Object message, final Throwable throwable) {
1600        if (isEnabled(level, marker, message, throwable)) {
1601            logMessage(FQCN, level, marker, message, throwable);
1602        }
1603    }
1604
1605    @Override
1606    public void log(final Level level, final Marker marker, final String message) {
1607        logIfEnabled(FQCN, level, marker, message, (Throwable) null);
1608    }
1609
1610    @Override
1611    public void log(final Level level, final Marker marker, final String message, final Object... params) {
1612        logIfEnabled(FQCN, level, marker, message, params);
1613    }
1614
1615    @Override
1616    public void log(final Level level, final Marker marker, final String message, final Throwable throwable) {
1617        logIfEnabled(FQCN, level, marker, message, throwable);
1618    }
1619
1620    @Override
1621    public void log(final Level level, final Message message) {
1622        logIfEnabled(FQCN, level, null, message, message != null ? message.getThrowable() : null);
1623    }
1624
1625    @Override
1626    public void log(final Level level, final Message message, final Throwable throwable) {
1627        logIfEnabled(FQCN, level, null, message, throwable);
1628    }
1629
1630    @Override
1631    public void log(final Level level, final CharSequence message) {
1632        logIfEnabled(FQCN, level, null, message, null);
1633    }
1634
1635    @Override
1636    public void log(final Level level, final CharSequence message, final Throwable throwable) {
1637        logIfEnabled(FQCN, level, null, message, throwable);
1638    }
1639
1640    @Override
1641    public void log(final Level level, final Object message) {
1642        logIfEnabled(FQCN, level, null, message, null);
1643    }
1644
1645    @Override
1646    public void log(final Level level, final Object message, final Throwable throwable) {
1647        logIfEnabled(FQCN, level, null, message, throwable);
1648    }
1649
1650    @Override
1651    public void log(final Level level, final String message) {
1652        logIfEnabled(FQCN, level, null, message, (Throwable) null);
1653    }
1654
1655    @Override
1656    public void log(final Level level, final String message, final Object... params) {
1657        logIfEnabled(FQCN, level, null, message, params);
1658    }
1659
1660    @Override
1661    public void log(final Level level, final String message, final Throwable throwable) {
1662        logIfEnabled(FQCN, level, null, message, throwable);
1663    }
1664
1665    @Override
1666    public void log(final Level level, final Supplier<?> messageSupplier) {
1667        logIfEnabled(FQCN, level, null, messageSupplier, (Throwable) null);
1668    }
1669
1670    @Override
1671    public void log(final Level level, final Supplier<?> messageSupplier, final Throwable throwable) {
1672        logIfEnabled(FQCN, level, null, messageSupplier, throwable);
1673    }
1674
1675    @Override
1676    public void log(final Level level, final Marker marker, final Supplier<?> messageSupplier) {
1677        logIfEnabled(FQCN, level, marker, messageSupplier, (Throwable) null);
1678    }
1679
1680    @Override
1681    public void log(final Level level, final Marker marker, final String message, final Supplier<?>... paramSuppliers) {
1682        logIfEnabled(FQCN, level, marker, message, paramSuppliers);
1683    }
1684
1685    @Override
1686    public void log(final Level level, final Marker marker, final Supplier<?> messageSupplier, final Throwable throwable) {
1687        logIfEnabled(FQCN, level, marker, messageSupplier, throwable);
1688    }
1689
1690    @Override
1691    public void log(final Level level, final String message, final Supplier<?>... paramSuppliers) {
1692        logIfEnabled(FQCN, level, null, message, paramSuppliers);
1693    }
1694
1695    @Override
1696    public void log(final Level level, final Marker marker, final MessageSupplier messageSupplier) {
1697        logIfEnabled(FQCN, level, marker, messageSupplier, (Throwable) null);
1698    }
1699
1700    @Override
1701    public void log(final Level level, final Marker marker, final MessageSupplier messageSupplier, final Throwable throwable) {
1702        logIfEnabled(FQCN, level, marker, messageSupplier, throwable);
1703    }
1704
1705    @Override
1706    public void log(final Level level, final MessageSupplier messageSupplier) {
1707        logIfEnabled(FQCN, level, null, messageSupplier, (Throwable) null);
1708    }
1709
1710    @Override
1711    public void log(final Level level, final MessageSupplier messageSupplier, final Throwable throwable) {
1712        logIfEnabled(FQCN, level, null, messageSupplier, throwable);
1713    }
1714
1715    @Override
1716    public void log(final Level level, final Marker marker, final String message, final Object p0) {
1717        logIfEnabled(FQCN, level, marker, message, p0);
1718    }
1719
1720    @Override
1721    public void log(final Level level, final Marker marker, final String message, final Object p0, final Object p1) {
1722        logIfEnabled(FQCN, level, marker, message, p0, p1);
1723    }
1724
1725    @Override
1726    public void log(final Level level, final Marker marker, final String message, final Object p0, final Object p1,
1727            final Object p2) {
1728        logIfEnabled(FQCN, level, marker, message, p0, p1, p2);
1729    }
1730
1731    @Override
1732    public void log(final Level level, final Marker marker, final String message, final Object p0, final Object p1,
1733            final Object p2, final Object p3) {
1734        logIfEnabled(FQCN, level, marker, message, p0, p1, p2, p3);
1735    }
1736
1737    @Override
1738    public void log(final Level level, final Marker marker, final String message, final Object p0, final Object p1,
1739            final Object p2, final Object p3, final Object p4) {
1740        logIfEnabled(FQCN, level, marker, message, p0, p1, p2, p3, p4);
1741    }
1742
1743    @Override
1744    public void log(final Level level, final Marker marker, final String message, final Object p0, final Object p1,
1745            final Object p2, final Object p3, final Object p4, final Object p5) {
1746        logIfEnabled(FQCN, level, marker, message, p0, p1, p2, p3, p4, p5);
1747    }
1748
1749    @Override
1750    public void log(final Level level, final Marker marker, final String message, final Object p0, final Object p1,
1751            final Object p2, final Object p3, final Object p4, final Object p5, final Object p6) {
1752        logIfEnabled(FQCN, level, marker, message, p0, p1, p2, p3, p4, p5, p6);
1753    }
1754
1755    @Override
1756    public void log(final Level level, final Marker marker, final String message, final Object p0, final Object p1,
1757            final Object p2, final Object p3, final Object p4, final Object p5,
1758            final Object p6, final Object p7) {
1759        logIfEnabled(FQCN, level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
1760    }
1761
1762    @Override
1763    public void log(final Level level, final Marker marker, final String message, final Object p0, final Object p1,
1764            final Object p2, final Object p3, final Object p4, final Object p5,
1765            final Object p6, final Object p7, final Object p8) {
1766        logIfEnabled(FQCN, level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
1767    }
1768
1769    @Override
1770    public void log(final Level level, final Marker marker, final String message, final Object p0, final Object p1,
1771            final Object p2, final Object p3, final Object p4, final Object p5,
1772            final Object p6, final Object p7, final Object p8, final Object p9) {
1773        logIfEnabled(FQCN, level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1774    }
1775
1776    @Override
1777    public void log(final Level level, final String message, final Object p0) {
1778        logIfEnabled(FQCN, level, null, message, p0);
1779    }
1780
1781    @Override
1782    public void log(final Level level, final String message, final Object p0, final Object p1) {
1783        logIfEnabled(FQCN, level, null, message, p0, p1);
1784    }
1785
1786    @Override
1787    public void log(final Level level, final String message, final Object p0, final Object p1, final Object p2) {
1788        logIfEnabled(FQCN, level, null, message, p0, p1, p2);
1789    }
1790
1791    @Override
1792    public void log(final Level level, final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
1793        logIfEnabled(FQCN, level, null, message, p0, p1, p2, p3);
1794    }
1795
1796    @Override
1797    public void log(final Level level, final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1798            final Object p4) {
1799        logIfEnabled(FQCN, level, null, message, p0, p1, p2, p3, p4);
1800    }
1801
1802    @Override
1803    public void log(final Level level, final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1804            final Object p4, final Object p5) {
1805        logIfEnabled(FQCN, level, null, message, p0, p1, p2, p3, p4, p5);
1806    }
1807
1808    @Override
1809    public void log(final Level level, final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1810            final Object p4, final Object p5, final Object p6) {
1811        logIfEnabled(FQCN, level, null, message, p0, p1, p2, p3, p4, p5, p6);
1812    }
1813
1814    @Override
1815    public void log(final Level level, final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1816            final Object p4, final Object p5, final Object p6, final Object p7) {
1817        logIfEnabled(FQCN, level, null, message, p0, p1, p2, p3, p4, p5, p6, p7);
1818    }
1819
1820    @Override
1821    public void log(final Level level, final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1822            final Object p4, final Object p5, final Object p6, final Object p7, final Object p8) {
1823        logIfEnabled(FQCN, level, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
1824    }
1825
1826    @Override
1827    public void log(final Level level, final String message, final Object p0, final Object p1, final Object p2, final Object p3,
1828            final Object p4, final Object p5, final Object p6, final Object p7, final Object p8, final Object p9) {
1829        logIfEnabled(FQCN, level, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1830    }
1831
1832    @Override
1833    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final Message message,
1834            final Throwable throwable) {
1835        if (isEnabled(level, marker, message, throwable)) {
1836            logMessageSafely(fqcn, level, marker, message, throwable);
1837        }
1838    }
1839
1840    @Override
1841    public void logIfEnabled(final String fqcn, final Level level, final Marker marker,
1842            final MessageSupplier messageSupplier, final Throwable throwable) {
1843        if (isEnabled(level, marker, messageSupplier, throwable)) {
1844            logMessage(fqcn, level, marker, messageSupplier, throwable);
1845        }
1846    }
1847
1848    @Override
1849    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final Object message,
1850            final Throwable throwable) {
1851        if (isEnabled(level, marker, message, throwable)) {
1852            logMessage(fqcn, level, marker, message, throwable);
1853        }
1854    }
1855
1856    @Override
1857    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final CharSequence message,
1858            final Throwable throwable) {
1859        if (isEnabled(level, marker, message, throwable)) {
1860            logMessage(fqcn, level, marker, message, throwable);
1861        }
1862    }
1863
1864    @Override
1865    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final Supplier<?> messageSupplier,
1866            final Throwable throwable) {
1867        if (isEnabled(level, marker, messageSupplier, throwable)) {
1868            logMessage(fqcn, level, marker, messageSupplier, throwable);
1869        }
1870    }
1871
1872    @Override
1873    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message) {
1874        if (isEnabled(level, marker, message)) {
1875            logMessage(fqcn, level, marker, message);
1876        }
1877    }
1878
1879    @Override
1880    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1881            final Supplier<?>... paramSuppliers) {
1882        if (isEnabled(level, marker, message)) {
1883            logMessage(fqcn, level, marker, message, paramSuppliers);
1884        }
1885    }
1886
1887    @Override
1888    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1889            final Object... params) {
1890        if (isEnabled(level, marker, message, params)) {
1891            logMessage(fqcn, level, marker, message, params);
1892        }
1893    }
1894
1895    @Override
1896    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1897            final Object p0) {
1898        if (isEnabled(level, marker, message, p0)) {
1899            logMessage(fqcn, level, marker, message, p0);
1900        }
1901    }
1902
1903    @Override
1904    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1905            final Object p0, final Object p1) {
1906        if (isEnabled(level, marker, message, p0, p1)) {
1907            logMessage(fqcn, level, marker, message, p0, p1);
1908        }
1909    }
1910
1911    @Override
1912    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1913            final Object p0, final Object p1, final Object p2) {
1914        if (isEnabled(level, marker, message, p0, p1, p2)) {
1915            logMessage(fqcn, level, marker, message, p0, p1, p2);
1916        }
1917    }
1918
1919    @Override
1920    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1921            final Object p0, final Object p1, final Object p2, final Object p3) {
1922        if (isEnabled(level, marker, message, p0, p1, p2, p3)) {
1923            logMessage(fqcn, level, marker, message, p0, p1, p2, p3);
1924        }
1925    }
1926
1927    @Override
1928    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1929            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
1930        if (isEnabled(level, marker, message, p0, p1, p2, p3, p4)) {
1931            logMessage(fqcn, level, marker, message, p0, p1, p2, p3, p4);
1932        }
1933    }
1934
1935    @Override
1936    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1937            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
1938        if (isEnabled(level, marker, message, p0, p1, p2, p3, p4, p5)) {
1939            logMessage(fqcn, level, marker, message, p0, p1, p2, p3, p4, p5);
1940        }
1941    }
1942
1943    @Override
1944    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1945            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
1946            final Object p6) {
1947        if (isEnabled(level, marker, message, p0, p1, p2, p3, p4, p5, p6)) {
1948            logMessage(fqcn, level, marker, message, p0, p1, p2, p3, p4, p5, p6);
1949        }
1950    }
1951
1952    @Override
1953    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1954            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
1955            final Object p6, final Object p7) {
1956        if (isEnabled(level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7)) {
1957            logMessage(fqcn, level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
1958        }
1959    }
1960
1961    @Override
1962    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1963            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
1964            final Object p6, final Object p7, final Object p8) {
1965        if (isEnabled(level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
1966            logMessage(fqcn, level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
1967        }
1968    }
1969
1970    @Override
1971    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1972            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
1973            final Object p6, final Object p7, final Object p8, final Object p9) {
1974        if (isEnabled(level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
1975            logMessage(fqcn, level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1976        }
1977    }
1978
1979    @Override
1980    public void logIfEnabled(final String fqcn, final Level level, final Marker marker, final String message,
1981            final Throwable throwable) {
1982        if (isEnabled(level, marker, message, throwable)) {
1983            logMessage(fqcn, level, marker, message, throwable);
1984        }
1985    }
1986
1987    protected void logMessage(final String fqcn, final Level level, final Marker marker, final CharSequence message,
1988            final Throwable throwable) {
1989        logMessageSafely(fqcn, level, marker, messageFactory.newMessage(message), throwable);
1990    }
1991
1992    protected void logMessage(final String fqcn, final Level level, final Marker marker, final Object message,
1993            final Throwable throwable) {
1994        logMessageSafely(fqcn, level, marker, messageFactory.newMessage(message), throwable);
1995    }
1996
1997    protected void logMessage(final String fqcn, final Level level, final Marker marker,
1998            final MessageSupplier messageSupplier, final Throwable throwable) {
1999        final Message message = LambdaUtil.get(messageSupplier);
2000        final Throwable effectiveThrowable = (throwable == null && message != null)
2001                ? message.getThrowable()
2002                : throwable;
2003        logMessageSafely(fqcn, level, marker, message, effectiveThrowable);
2004    }
2005
2006    protected void logMessage(final String fqcn, final Level level, final Marker marker, final Supplier<?> messageSupplier,
2007            final Throwable throwable) {
2008        final Message message = LambdaUtil.getMessage(messageSupplier, messageFactory);
2009        final Throwable effectiveThrowable = (throwable == null && message != null)
2010                ? message.getThrowable()
2011                : throwable;
2012        logMessageSafely(fqcn, level, marker, message, effectiveThrowable);
2013    }
2014
2015    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2016            final Throwable throwable) {
2017        logMessageSafely(fqcn, level, marker, messageFactory.newMessage(message), throwable);
2018    }
2019
2020    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message) {
2021        final Message msg = messageFactory.newMessage(message);
2022        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2023    }
2024
2025    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2026            final Object... params) {
2027        final Message msg = messageFactory.newMessage(message, params);
2028        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2029    }
2030
2031    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2032            final Object p0) {
2033        final Message msg = messageFactory.newMessage(message, p0);
2034        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2035    }
2036
2037    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2038            final Object p0, final Object p1) {
2039        final Message msg = messageFactory.newMessage(message, p0, p1);
2040        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2041    }
2042
2043    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2044            final Object p0, final Object p1, final Object p2) {
2045        final Message msg = messageFactory.newMessage(message, p0, p1, p2);
2046        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2047    }
2048
2049    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2050            final Object p0, final Object p1, final Object p2, final Object p3) {
2051        final Message msg = messageFactory.newMessage(message, p0, p1, p2, p3);
2052        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2053    }
2054
2055    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2056            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
2057        final Message msg = messageFactory.newMessage(message, p0, p1, p2, p3, p4);
2058        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2059    }
2060
2061    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2062            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
2063        final Message msg = messageFactory.newMessage(message, p0, p1, p2, p3, p4, p5);
2064        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2065    }
2066
2067    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2068            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
2069            final Object p6) {
2070        final Message msg = messageFactory.newMessage(message, p0, p1, p2, p3, p4, p5, p6);
2071        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2072    }
2073
2074    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2075            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
2076            final Object p6, final Object p7) {
2077        final Message msg = messageFactory.newMessage(message, p0, p1, p2, p3, p4, p5, p6, p7);
2078        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2079    }
2080
2081    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2082            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
2083            final Object p6, final Object p7, final Object p8) {
2084        final Message msg = messageFactory.newMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
2085        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2086    }
2087
2088    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2089            final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
2090            final Object p6, final Object p7, final Object p8, final Object p9) {
2091        final Message msg = messageFactory.newMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2092        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2093    }
2094
2095    protected void logMessage(final String fqcn, final Level level, final Marker marker, final String message,
2096            final Supplier<?>... paramSuppliers) {
2097        final Message msg = messageFactory.newMessage(message, LambdaUtil.getAll(paramSuppliers));
2098        logMessageSafely(fqcn, level, marker, msg, msg.getThrowable());
2099    }
2100
2101    @Override
2102    public void logMessage(final Level level, final Marker marker, final String fqcn, final StackTraceElement location,
2103        final Message message, final Throwable throwable) {
2104        try {
2105            incrementRecursionDepth();
2106            log(level, marker, fqcn, location, message, throwable);
2107        } catch (Throwable ex) {
2108            handleLogMessageException(ex, fqcn, message);
2109        } finally {
2110            decrementRecursionDepth();
2111            ReusableMessageFactory.release(message);
2112        }
2113    }
2114
2115    protected void log(final Level level, final Marker marker, final String fqcn, final StackTraceElement location,
2116        final Message message, final Throwable throwable) {
2117        logMessage(fqcn, level, marker, message, throwable);
2118    }
2119
2120    @Override
2121    public void printf(final Level level, final Marker marker, final String format, final Object... params) {
2122        if (isEnabled(level, marker, format, params)) {
2123            final Message message = new StringFormattedMessage(format, params);
2124            logMessageSafely(FQCN, level, marker, message, message.getThrowable());
2125        }
2126    }
2127
2128    @Override
2129    public void printf(final Level level, final String format, final Object... params) {
2130        if (isEnabled(level, null, format, params)) {
2131            final Message message = new StringFormattedMessage(format, params);
2132            logMessageSafely(FQCN, level, null, message, message.getThrowable());
2133        }
2134    }
2135
2136    @PerformanceSensitive
2137    // NOTE: This is a hot method. Current implementation compiles to 30 bytes of byte code.
2138    // This is within the 35 byte MaxInlineSize threshold. Modify with care!
2139    private void logMessageSafely(final String fqcn, final Level level, final Marker marker, final Message message,
2140            final Throwable throwable) {
2141        try {
2142            logMessageTrackRecursion(fqcn, level, marker, message, throwable);
2143        } finally {
2144            // LOG4J2-1583 prevent scrambled logs when logging calls are nested (logging in toString())
2145            ReusableMessageFactory.release(message);
2146        }
2147    }
2148
2149    @PerformanceSensitive
2150    // NOTE: This is a hot method. Current implementation compiles to 33 bytes of byte code.
2151    // This is within the 35 byte MaxInlineSize threshold. Modify with care!
2152    private void logMessageTrackRecursion(final String fqcn,
2153                                          final Level level,
2154                                          final Marker marker,
2155                                          final Message message,
2156                                          final Throwable throwable) {
2157        try {
2158            incrementRecursionDepth(); // LOG4J2-1518, LOG4J2-2031
2159            tryLogMessage(fqcn, getLocation(fqcn), level, marker, message, throwable);
2160        } finally {
2161            decrementRecursionDepth();
2162        }
2163    }
2164
2165    private static int[] getRecursionDepthHolder() {
2166        int[] result = recursionDepthHolder.get();
2167        if (result == null) {
2168            result = new int[1];
2169            recursionDepthHolder.set(result);
2170        }
2171        return result;
2172    }
2173
2174    private static void incrementRecursionDepth() {
2175        getRecursionDepthHolder()[0]++;
2176    }
2177
2178    private static void decrementRecursionDepth() {
2179        int newDepth = --getRecursionDepthHolder()[0];
2180        if (newDepth < 0) {
2181            throw new IllegalStateException("Recursion depth became negative: " + newDepth);
2182        }
2183    }
2184
2185    /**
2186     * Returns the depth of nested logging calls in the current Thread: zero if no logging call has been made,
2187     * one if a single logging call without nested logging calls has been made, or more depending on the level of
2188     * nesting.
2189     * @return the depth of the nested logging calls in the current Thread
2190     */
2191    public static int getRecursionDepth() {
2192        return getRecursionDepthHolder()[0];
2193    }
2194
2195    @PerformanceSensitive
2196    // NOTE: This is a hot method. Current implementation compiles to 26 bytes of byte code.
2197    // This is within the 35 byte MaxInlineSize threshold. Modify with care!
2198    private void tryLogMessage(final String fqcn,
2199                               final StackTraceElement location,
2200                               final Level level,
2201                               final Marker marker,
2202                               final Message message,
2203                               final Throwable throwable) {
2204        try {
2205            log(level, marker, fqcn, location, message, throwable);
2206        } catch (final Throwable t) {
2207            // LOG4J2-1990 Log4j2 suppresses all exceptions that occur once application called the logger
2208            handleLogMessageException(t, fqcn, message);
2209        }
2210    }
2211
2212    @PerformanceSensitive
2213    // NOTE: This is a hot method. Current implementation compiles to 15 bytes of byte code.
2214    // This is within the 35 byte MaxInlineSize threshold. Modify with care!
2215    private StackTraceElement getLocation(String fqcn) {
2216        return requiresLocation() ? StackLocatorUtil.calcLocation(fqcn) : null;
2217    }
2218
2219    // LOG4J2-1990 Log4j2 suppresses all exceptions that occur once application called the logger
2220    // TODO Configuration setting to propagate exceptions back to the caller *if requested*
2221    private void handleLogMessageException(final Throwable throwable, final String fqcn, final Message message) {
2222        if (throwable instanceof LoggingException) {
2223            throw (LoggingException) throwable;
2224        }
2225        StatusLogger.getLogger().warn("{} caught {} logging {}: {}",
2226                fqcn,
2227                throwable.getClass().getName(),
2228                message.getClass().getSimpleName(),
2229                message.getFormat(),
2230                throwable);
2231    }
2232
2233    @Override
2234    public <T extends Throwable> T throwing(final T throwable) {
2235        return throwing(FQCN, Level.ERROR, throwable);
2236    }
2237
2238    @Override
2239    public <T extends Throwable> T throwing(final Level level, final T throwable) {
2240        return throwing(FQCN, level, throwable);
2241    }
2242
2243    /**
2244     * Logs a Throwable to be thrown.
2245     *
2246     * @param <T> the type of the Throwable.
2247     * @param fqcn the fully qualified class name of this Logger implementation.
2248     * @param level The logging Level.
2249     * @param throwable The Throwable.
2250     * @return the Throwable.
2251     */
2252    protected <T extends Throwable> T throwing(final String fqcn, final Level level, final T throwable) {
2253        if (isEnabled(level, THROWING_MARKER, (Object) null, null)) {
2254            logMessageSafely(fqcn, level, THROWING_MARKER, throwingMsg(throwable), throwable);
2255        }
2256        return throwable;
2257    }
2258
2259    protected Message throwingMsg(final Throwable throwable) {
2260        return messageFactory.newMessage(THROWING);
2261    }
2262
2263    @Override
2264    public void trace(final Marker marker, final Message message) {
2265        logIfEnabled(FQCN, Level.TRACE, marker, message, message != null ? message.getThrowable() : null);
2266    }
2267
2268    @Override
2269    public void trace(final Marker marker, final Message message, final Throwable throwable) {
2270        logIfEnabled(FQCN, Level.TRACE, marker, message, throwable);
2271    }
2272
2273    @Override
2274    public void trace(final Marker marker, final CharSequence message) {
2275        logIfEnabled(FQCN, Level.TRACE, marker, message, null);
2276    }
2277
2278    @Override
2279    public void trace(final Marker marker, final CharSequence message, final Throwable throwable) {
2280        logIfEnabled(FQCN, Level.TRACE, marker, message, throwable);
2281    }
2282
2283    @Override
2284    public void trace(final Marker marker, final Object message) {
2285        logIfEnabled(FQCN, Level.TRACE, marker, message, null);
2286    }
2287
2288    @Override
2289    public void trace(final Marker marker, final Object message, final Throwable throwable) {
2290        logIfEnabled(FQCN, Level.TRACE, marker, message, throwable);
2291    }
2292
2293    @Override
2294    public void trace(final Marker marker, final String message) {
2295        logIfEnabled(FQCN, Level.TRACE, marker, message, (Throwable) null);
2296    }
2297
2298    @Override
2299    public void trace(final Marker marker, final String message, final Object... params) {
2300        logIfEnabled(FQCN, Level.TRACE, marker, message, params);
2301    }
2302
2303    @Override
2304    public void trace(final Marker marker, final String message, final Throwable throwable) {
2305        logIfEnabled(FQCN, Level.TRACE, marker, message, throwable);
2306    }
2307
2308    @Override
2309    public void trace(final Message message) {
2310        logIfEnabled(FQCN, Level.TRACE, null, message, message != null ? message.getThrowable() : null);
2311    }
2312
2313    @Override
2314    public void trace(final Message message, final Throwable throwable) {
2315        logIfEnabled(FQCN, Level.TRACE, null, message, throwable);
2316    }
2317
2318    @Override
2319    public void trace(final CharSequence message) {
2320        logIfEnabled(FQCN, Level.TRACE, null, message, null);
2321    }
2322
2323    @Override
2324    public void trace(final CharSequence message, final Throwable throwable) {
2325        logIfEnabled(FQCN, Level.TRACE, null, message, throwable);
2326    }
2327
2328    @Override
2329    public void trace(final Object message) {
2330        logIfEnabled(FQCN, Level.TRACE, null, message, null);
2331    }
2332
2333    @Override
2334    public void trace(final Object message, final Throwable throwable) {
2335        logIfEnabled(FQCN, Level.TRACE, null, message, throwable);
2336    }
2337
2338    @Override
2339    public void trace(final String message) {
2340        logIfEnabled(FQCN, Level.TRACE, null, message, (Throwable) null);
2341    }
2342
2343    @Override
2344    public void trace(final String message, final Object... params) {
2345        logIfEnabled(FQCN, Level.TRACE, null, message, params);
2346    }
2347
2348    @Override
2349    public void trace(final String message, final Throwable throwable) {
2350        logIfEnabled(FQCN, Level.TRACE, null, message, throwable);
2351    }
2352
2353    @Override
2354    public void trace(final Supplier<?> messageSupplier) {
2355        logIfEnabled(FQCN, Level.TRACE, null, messageSupplier, (Throwable) null);
2356    }
2357
2358    @Override
2359    public void trace(final Supplier<?> messageSupplier, final Throwable throwable) {
2360        logIfEnabled(FQCN, Level.TRACE, null, messageSupplier, throwable);
2361    }
2362
2363    @Override
2364    public void trace(final Marker marker, final Supplier<?> messageSupplier) {
2365        logIfEnabled(FQCN, Level.TRACE, marker, messageSupplier, (Throwable) null);
2366    }
2367
2368    @Override
2369    public void trace(final Marker marker, final String message, final Supplier<?>... paramSuppliers) {
2370        logIfEnabled(FQCN, Level.TRACE, marker, message, paramSuppliers);
2371    }
2372
2373    @Override
2374    public void trace(final Marker marker, final Supplier<?> messageSupplier, final Throwable throwable) {
2375        logIfEnabled(FQCN, Level.TRACE, marker, messageSupplier, throwable);
2376    }
2377
2378    @Override
2379    public void trace(final String message, final Supplier<?>... paramSuppliers) {
2380        logIfEnabled(FQCN, Level.TRACE, null, message, paramSuppliers);
2381    }
2382
2383    @Override
2384    public void trace(final Marker marker, final MessageSupplier messageSupplier) {
2385        logIfEnabled(FQCN, Level.TRACE, marker, messageSupplier, (Throwable) null);
2386    }
2387
2388    @Override
2389    public void trace(final Marker marker, final MessageSupplier messageSupplier, final Throwable throwable) {
2390        logIfEnabled(FQCN, Level.TRACE, marker, messageSupplier, throwable);
2391    }
2392
2393    @Override
2394    public void trace(final MessageSupplier messageSupplier) {
2395        logIfEnabled(FQCN, Level.TRACE, null, messageSupplier, (Throwable) null);
2396    }
2397
2398    @Override
2399    public void trace(final MessageSupplier messageSupplier, final Throwable throwable) {
2400        logIfEnabled(FQCN, Level.TRACE, null, messageSupplier, throwable);
2401    }
2402
2403    @Override
2404    public void trace(final Marker marker, final String message, final Object p0) {
2405        logIfEnabled(FQCN, Level.TRACE, marker, message, p0);
2406    }
2407
2408    @Override
2409    public void trace(final Marker marker, final String message, final Object p0, final Object p1) {
2410        logIfEnabled(FQCN, Level.TRACE, marker, message, p0, p1);
2411    }
2412
2413    @Override
2414    public void trace(final Marker marker, final String message, final Object p0, final Object p1, final Object p2) {
2415        logIfEnabled(FQCN, Level.TRACE, marker, message, p0, p1, p2);
2416    }
2417
2418    @Override
2419    public void trace(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2420            final Object p3) {
2421        logIfEnabled(FQCN, Level.TRACE, marker, message, p0, p1, p2, p3);
2422    }
2423
2424    @Override
2425    public void trace(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2426            final Object p3, final Object p4) {
2427        logIfEnabled(FQCN, Level.TRACE, marker, message, p0, p1, p2, p3, p4);
2428    }
2429
2430    @Override
2431    public void trace(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2432            final Object p3, final Object p4, final Object p5) {
2433        logIfEnabled(FQCN, Level.TRACE, marker, message, p0, p1, p2, p3, p4, p5);
2434    }
2435
2436    @Override
2437    public void trace(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2438            final Object p3, final Object p4, final Object p5, final Object p6) {
2439        logIfEnabled(FQCN, Level.TRACE, marker, message, p0, p1, p2, p3, p4, p5, p6);
2440    }
2441
2442    @Override
2443    public void trace(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2444            final Object p3, final Object p4, final Object p5, final Object p6, final Object p7) {
2445        logIfEnabled(FQCN, Level.TRACE, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
2446    }
2447
2448    @Override
2449    public void trace(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2450            final Object p3, final Object p4, final Object p5,
2451            final Object p6, final Object p7, final Object p8) {
2452        logIfEnabled(FQCN, Level.TRACE, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
2453    }
2454
2455    @Override
2456    public void trace(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2457            final Object p3, final Object p4, final Object p5,
2458            final Object p6, final Object p7, final Object p8, final Object p9) {
2459        logIfEnabled(FQCN, Level.TRACE, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2460    }
2461
2462    @Override
2463    public void trace(final String message, final Object p0) {
2464        logIfEnabled(FQCN, Level.TRACE, null, message, p0);
2465    }
2466
2467    @Override
2468    public void trace(final String message, final Object p0, final Object p1) {
2469        logIfEnabled(FQCN, Level.TRACE, null, message, p0, p1);
2470    }
2471
2472    @Override
2473    public void trace(final String message, final Object p0, final Object p1, final Object p2) {
2474        logIfEnabled(FQCN, Level.TRACE, null, message, p0, p1, p2);
2475    }
2476
2477    @Override
2478    public void trace(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
2479        logIfEnabled(FQCN, Level.TRACE, null, message, p0, p1, p2, p3);
2480    }
2481
2482    @Override
2483    public void trace(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2484            final Object p4) {
2485        logIfEnabled(FQCN, Level.TRACE, null, message, p0, p1, p2, p3, p4);
2486    }
2487
2488    @Override
2489    public void trace(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2490            final Object p4, final Object p5) {
2491        logIfEnabled(FQCN, Level.TRACE, null, message, p0, p1, p2, p3, p4, p5);
2492    }
2493
2494    @Override
2495    public void trace(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2496            final Object p4, final Object p5, final Object p6) {
2497        logIfEnabled(FQCN, Level.TRACE, null, message, p0, p1, p2, p3, p4, p5, p6);
2498    }
2499
2500    @Override
2501    public void trace(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2502            final Object p4, final Object p5, final Object p6, final Object p7) {
2503        logIfEnabled(FQCN, Level.TRACE, null, message, p0, p1, p2, p3, p4, p5, p6, p7);
2504    }
2505
2506    @Override
2507    public void trace(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2508            final Object p4, final Object p5, final Object p6, final Object p7, final Object p8) {
2509        logIfEnabled(FQCN, Level.TRACE, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
2510    }
2511
2512    @Override
2513    public void trace(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2514            final Object p4, final Object p5, final Object p6, final Object p7, final Object p8, final Object p9) {
2515        logIfEnabled(FQCN, Level.TRACE, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2516    }
2517
2518    @Override
2519    public EntryMessage traceEntry() {
2520        return enter(FQCN, null, (Object[]) null);
2521    }
2522
2523    @Override
2524    public EntryMessage traceEntry(final String format, final Object... params) {
2525        return enter(FQCN, format, params);
2526    }
2527
2528    @Override
2529    public EntryMessage traceEntry(final Supplier<?>... paramSuppliers) {
2530        return enter(FQCN, null, paramSuppliers);
2531    }
2532
2533    @Override
2534    public EntryMessage traceEntry(final String format, final Supplier<?>... paramSuppliers) {
2535        return enter(FQCN, format, paramSuppliers);
2536    }
2537
2538    @Override
2539    public EntryMessage traceEntry(final Message message) {
2540        return enter(FQCN, message);
2541    }
2542
2543    @Override
2544    public void traceExit() {
2545        exit(FQCN, null, null);
2546    }
2547
2548    @Override
2549    public <R> R traceExit(final R result) {
2550        return exit(FQCN, null, result);
2551    }
2552
2553    @Override
2554    public <R> R traceExit(final String format, final R result) {
2555        return exit(FQCN, format, result);
2556    }
2557
2558    @Override
2559    public void traceExit(final EntryMessage message) {
2560        // If the message is null, traceEnter returned null because flow logging was disabled, we can optimize out calling isEnabled().
2561        if (message != null && isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
2562            logMessageSafely(FQCN, Level.TRACE, EXIT_MARKER, flowMessageFactory.newExitMessage(message), null);
2563        }
2564    }
2565
2566    @Override
2567    public <R> R traceExit(final EntryMessage message, final R result) {
2568        // If the message is null, traceEnter returned null because flow logging was disabled, we can optimize out calling isEnabled().
2569        if (message != null && isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
2570            logMessageSafely(FQCN, Level.TRACE, EXIT_MARKER, flowMessageFactory.newExitMessage(result, message), null);
2571        }
2572        return result;
2573    }
2574
2575    @Override
2576    public <R> R traceExit(final Message message, final R result) {
2577        // If the message is null, traceEnter returned null because flow logging was disabled, we can optimize out calling isEnabled().
2578        if (message != null && isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
2579            logMessageSafely(FQCN, Level.TRACE, EXIT_MARKER, flowMessageFactory.newExitMessage(result, message), null);
2580        }
2581        return result;
2582    }
2583
2584    @Override
2585    public void warn(final Marker marker, final Message message) {
2586        logIfEnabled(FQCN, Level.WARN, marker, message, message != null ? message.getThrowable() : null);
2587    }
2588
2589    @Override
2590    public void warn(final Marker marker, final Message message, final Throwable throwable) {
2591        logIfEnabled(FQCN, Level.WARN, marker, message, throwable);
2592    }
2593
2594    @Override
2595    public void warn(final Marker marker, final CharSequence message) {
2596        logIfEnabled(FQCN, Level.WARN, marker, message, null);
2597    }
2598
2599    @Override
2600    public void warn(final Marker marker, final CharSequence message, final Throwable throwable) {
2601        logIfEnabled(FQCN, Level.WARN, marker, message, throwable);
2602    }
2603
2604    @Override
2605    public void warn(final Marker marker, final Object message) {
2606        logIfEnabled(FQCN, Level.WARN, marker, message, null);
2607    }
2608
2609    @Override
2610    public void warn(final Marker marker, final Object message, final Throwable throwable) {
2611        logIfEnabled(FQCN, Level.WARN, marker, message, throwable);
2612    }
2613
2614    @Override
2615    public void warn(final Marker marker, final String message) {
2616        logIfEnabled(FQCN, Level.WARN, marker, message, (Throwable) null);
2617    }
2618
2619    @Override
2620    public void warn(final Marker marker, final String message, final Object... params) {
2621        logIfEnabled(FQCN, Level.WARN, marker, message, params);
2622    }
2623
2624    @Override
2625    public void warn(final Marker marker, final String message, final Throwable throwable) {
2626        logIfEnabled(FQCN, Level.WARN, marker, message, throwable);
2627    }
2628
2629    @Override
2630    public void warn(final Message message) {
2631        logIfEnabled(FQCN, Level.WARN, null, message, message != null ? message.getThrowable() : null);
2632    }
2633
2634    @Override
2635    public void warn(final Message message, final Throwable throwable) {
2636        logIfEnabled(FQCN, Level.WARN, null, message, throwable);
2637    }
2638
2639    @Override
2640    public void warn(final CharSequence message) {
2641        logIfEnabled(FQCN, Level.WARN, null, message, null);
2642    }
2643
2644    @Override
2645    public void warn(final CharSequence message, final Throwable throwable) {
2646        logIfEnabled(FQCN, Level.WARN, null, message, throwable);
2647    }
2648
2649    @Override
2650    public void warn(final Object message) {
2651        logIfEnabled(FQCN, Level.WARN, null, message, null);
2652    }
2653
2654    @Override
2655    public void warn(final Object message, final Throwable throwable) {
2656        logIfEnabled(FQCN, Level.WARN, null, message, throwable);
2657    }
2658
2659    @Override
2660    public void warn(final String message) {
2661        logIfEnabled(FQCN, Level.WARN, null, message, (Throwable) null);
2662    }
2663
2664    @Override
2665    public void warn(final String message, final Object... params) {
2666        logIfEnabled(FQCN, Level.WARN, null, message, params);
2667    }
2668
2669    @Override
2670    public void warn(final String message, final Throwable throwable) {
2671        logIfEnabled(FQCN, Level.WARN, null, message, throwable);
2672    }
2673
2674    @Override
2675    public void warn(final Supplier<?> messageSupplier) {
2676        logIfEnabled(FQCN, Level.WARN, null, messageSupplier, (Throwable) null);
2677    }
2678
2679    @Override
2680    public void warn(final Supplier<?> messageSupplier, final Throwable throwable) {
2681        logIfEnabled(FQCN, Level.WARN, null, messageSupplier, throwable);
2682    }
2683
2684    @Override
2685    public void warn(final Marker marker, final Supplier<?> messageSupplier) {
2686        logIfEnabled(FQCN, Level.WARN, marker, messageSupplier, (Throwable) null);
2687    }
2688
2689    @Override
2690    public void warn(final Marker marker, final String message, final Supplier<?>... paramSuppliers) {
2691        logIfEnabled(FQCN, Level.WARN, marker, message, paramSuppliers);
2692    }
2693
2694    @Override
2695    public void warn(final Marker marker, final Supplier<?> messageSupplier, final Throwable throwable) {
2696        logIfEnabled(FQCN, Level.WARN, marker, messageSupplier, throwable);
2697    }
2698
2699    @Override
2700    public void warn(final String message, final Supplier<?>... paramSuppliers) {
2701        logIfEnabled(FQCN, Level.WARN, null, message, paramSuppliers);
2702    }
2703
2704    @Override
2705    public void warn(final Marker marker, final MessageSupplier messageSupplier) {
2706        logIfEnabled(FQCN, Level.WARN, marker, messageSupplier, (Throwable) null);
2707    }
2708
2709    @Override
2710    public void warn(final Marker marker, final MessageSupplier messageSupplier, final Throwable throwable) {
2711        logIfEnabled(FQCN, Level.WARN, marker, messageSupplier, throwable);
2712    }
2713
2714    @Override
2715    public void warn(final MessageSupplier messageSupplier) {
2716        logIfEnabled(FQCN, Level.WARN, null, messageSupplier, (Throwable) null);
2717    }
2718
2719    @Override
2720    public void warn(final MessageSupplier messageSupplier, final Throwable throwable) {
2721        logIfEnabled(FQCN, Level.WARN, null, messageSupplier, throwable);
2722    }
2723
2724    @Override
2725    public void warn(final Marker marker, final String message, final Object p0) {
2726        logIfEnabled(FQCN, Level.WARN, marker, message, p0);
2727    }
2728
2729    @Override
2730    public void warn(final Marker marker, final String message, final Object p0, final Object p1) {
2731        logIfEnabled(FQCN, Level.WARN, marker, message, p0, p1);
2732    }
2733
2734    @Override
2735    public void warn(final Marker marker, final String message, final Object p0, final Object p1, final Object p2) {
2736        logIfEnabled(FQCN, Level.WARN, marker, message, p0, p1, p2);
2737    }
2738
2739    @Override
2740    public void warn(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2741            final Object p3) {
2742        logIfEnabled(FQCN, Level.WARN, marker, message, p0, p1, p2, p3);
2743    }
2744
2745    @Override
2746    public void warn(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2747            final Object p3, final Object p4) {
2748        logIfEnabled(FQCN, Level.WARN, marker, message, p0, p1, p2, p3, p4);
2749    }
2750
2751    @Override
2752    public void warn(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2753            final Object p3, final Object p4, final Object p5) {
2754        logIfEnabled(FQCN, Level.WARN, marker, message, p0, p1, p2, p3, p4, p5);
2755    }
2756
2757    @Override
2758    public void warn(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2759            final Object p3, final Object p4, final Object p5, final Object p6) {
2760        logIfEnabled(FQCN, Level.WARN, marker, message, p0, p1, p2, p3, p4, p5, p6);
2761    }
2762
2763    @Override
2764    public void warn(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2765            final Object p3, final Object p4, final Object p5, final Object p6, final Object p7) {
2766        logIfEnabled(FQCN, Level.WARN, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
2767    }
2768
2769    @Override
2770    public void warn(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2771            final Object p3, final Object p4, final Object p5, final Object p6, final Object p7, final Object p8) {
2772        logIfEnabled(FQCN, Level.WARN, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
2773    }
2774
2775    @Override
2776    public void warn(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
2777            final Object p3, final Object p4, final Object p5,
2778            final Object p6, final Object p7, final Object p8, final Object p9) {
2779        logIfEnabled(FQCN, Level.WARN, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2780    }
2781
2782    @Override
2783    public void warn(final String message, final Object p0) {
2784        logIfEnabled(FQCN, Level.WARN, null, message, p0);
2785    }
2786
2787    @Override
2788    public void warn(final String message, final Object p0, final Object p1) {
2789        logIfEnabled(FQCN, Level.WARN, null, message, p0, p1);
2790    }
2791
2792    @Override
2793    public void warn(final String message, final Object p0, final Object p1, final Object p2) {
2794        logIfEnabled(FQCN, Level.WARN, null, message, p0, p1, p2);
2795    }
2796
2797    @Override
2798    public void warn(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
2799        logIfEnabled(FQCN, Level.WARN, null, message, p0, p1, p2, p3);
2800    }
2801
2802    @Override
2803    public void warn(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2804            final Object p4) {
2805        logIfEnabled(FQCN, Level.WARN, null, message, p0, p1, p2, p3, p4);
2806    }
2807
2808    @Override
2809    public void warn(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2810            final Object p4, final Object p5) {
2811        logIfEnabled(FQCN, Level.WARN, null, message, p0, p1, p2, p3, p4, p5);
2812    }
2813
2814    @Override
2815    public void warn(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2816            final Object p4, final Object p5, final Object p6) {
2817        logIfEnabled(FQCN, Level.WARN, null, message, p0, p1, p2, p3, p4, p5, p6);
2818    }
2819
2820    @Override
2821    public void warn(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2822            final Object p4, final Object p5, final Object p6, final Object p7) {
2823        logIfEnabled(FQCN, Level.WARN, null, message, p0, p1, p2, p3, p4, p5, p6, p7);
2824    }
2825
2826    @Override
2827    public void warn(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2828            final Object p4, final Object p5, final Object p6, final Object p7, final Object p8) {
2829        logIfEnabled(FQCN, Level.WARN, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
2830    }
2831
2832    @Override
2833    public void warn(final String message, final Object p0, final Object p1, final Object p2, final Object p3,
2834            final Object p4, final Object p5, final Object p6,
2835            final Object p7, final Object p8, final Object p9) {
2836        logIfEnabled(FQCN, Level.WARN, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2837    }
2838
2839    protected boolean requiresLocation() {
2840        return false;
2841    }
2842
2843    /**
2844     * Construct a trace log event.
2845     * @return a LogBuilder.
2846     * @since 2.13.0
2847     */
2848    @Override
2849    public LogBuilder atTrace() {
2850        return atLevel(Level.TRACE);
2851    }
2852    /**
2853     * Construct a debug log event.
2854     * @return a LogBuilder.
2855     * @since 2.13.0
2856     */
2857    @Override
2858    public LogBuilder atDebug() {
2859        return atLevel(Level.DEBUG);
2860    }
2861    /**
2862     * Construct an informational log event.
2863     * @return a LogBuilder.
2864     * @since 2.13.0
2865     */
2866    @Override
2867    public LogBuilder atInfo() {
2868        return atLevel(Level.INFO);
2869    }
2870    /**
2871     * Construct a warning log event.
2872     * @return a LogBuilder.
2873     * @since 2.13.0
2874     */
2875    @Override
2876    public LogBuilder atWarn() {
2877        return atLevel(Level.WARN);
2878    }
2879    /**
2880     * Construct an error log event.
2881     * @return a LogBuilder.
2882     * @since 2.13.0
2883     */
2884    @Override
2885    public LogBuilder atError() {
2886        return atLevel(Level.ERROR);
2887    }
2888    /**
2889     * Construct a fatal log event.
2890     * @return a LogBuilder.
2891     * @since 2.13.0
2892     */
2893    @Override
2894    public LogBuilder atFatal() {
2895        return atLevel(Level.FATAL);
2896    }
2897    /**
2898     * Construct a fatal log event.
2899     * @return a LogBuilder.
2900     * @since 2.13.0
2901     */
2902    @Override
2903    public LogBuilder always() {
2904        DefaultLogBuilder builder = logBuilder.get();
2905        if (builder.isInUse()) {
2906            return new DefaultLogBuilder(this);
2907        }
2908        return builder.reset(Level.OFF);
2909    }
2910    /**
2911     * Construct a log event.
2912     * @return a LogBuilder.
2913     * @since 2.13.0
2914     */
2915    @Override
2916    public LogBuilder atLevel(Level level) {
2917        if (isEnabled(level)) {
2918            return getLogBuilder(level).reset(level);
2919        }
2920        return LogBuilder.NOOP;
2921    }
2922
2923    private DefaultLogBuilder getLogBuilder(Level level) {
2924        DefaultLogBuilder builder = logBuilder.get();
2925        return Constants.ENABLE_THREADLOCALS && !builder.isInUse() ? builder : new DefaultLogBuilder(this, level);
2926    }
2927
2928    private void readObject (final ObjectInputStream s) throws ClassNotFoundException, IOException {
2929        s.defaultReadObject( );
2930        try {
2931            Field f = this.getClass().getDeclaredField("logBuilder");
2932            f.setAccessible(true);
2933            f.set(this, new LocalLogBuilder(this));
2934        } catch (NoSuchFieldException | IllegalAccessException ex) {
2935            StatusLogger.getLogger().warn("Unable to initialize LogBuilder");
2936        }
2937    }
2938
2939    private class LocalLogBuilder extends ThreadLocal<DefaultLogBuilder> {
2940        private AbstractLogger logger;
2941        LocalLogBuilder(AbstractLogger logger) {
2942            this.logger = logger;
2943        }
2944
2945        @Override
2946        protected DefaultLogBuilder initialValue() {
2947            return new DefaultLogBuilder(logger);
2948        }
2949    }
2950}