001package org.slf4j.jul;
002
003import org.slf4j.ILoggerFactory;
004import org.slf4j.IMarkerFactory;
005import org.slf4j.helpers.BasicMDCAdapter;
006import org.slf4j.helpers.BasicMarkerFactory;
007import org.slf4j.spi.MDCAdapter;
008import org.slf4j.spi.SLF4JServiceProvider;
009
010public class JULServiceProvider implements SLF4JServiceProvider {
011
012    /**
013     * Declare the version of the SLF4J API this implementation is compiled
014     * against. The value of this field is modified with each major release.
015     */
016    // to avoid constant folding by the compiler, this field must *not* be final
017    public static String REQUESTED_API_VERSION = "2.0.99"; // !final
018
019    private ILoggerFactory loggerFactory;
020    private IMarkerFactory markerFactory;
021    private MDCAdapter mdcAdapter;
022
023    @Override
024    public ILoggerFactory getLoggerFactory() {
025        return loggerFactory;
026    }
027
028    @Override
029    public IMarkerFactory getMarkerFactory() {
030        return markerFactory;
031    }
032
033    public MDCAdapter getMDCAdapter() {
034        return mdcAdapter;
035    }
036
037    @Override
038    public String getRequestedApiVersion() {
039        return REQUESTED_API_VERSION;
040    }
041
042    @Override
043    public void initialize() {
044        loggerFactory = new JDK14LoggerFactory();
045        markerFactory = new BasicMarkerFactory();
046        mdcAdapter = new BasicMDCAdapter();
047    }
048}