001package org.slf4j.reload4j;
002
003import org.apache.log4j.Level;
004import org.slf4j.ILoggerFactory;
005import org.slf4j.IMarkerFactory;
006import org.slf4j.helpers.BasicMarkerFactory;
007import org.slf4j.helpers.Reporter;
008import org.slf4j.helpers.Util;
009import org.slf4j.spi.MDCAdapter;
010import org.slf4j.spi.SLF4JServiceProvider;
011
012public class Reload4jServiceProvider implements SLF4JServiceProvider {
013
014    /**
015     * Declare the version of the SLF4J API this implementation is compiled against. 
016     * The value of this field is modified with each major release. 
017     */
018    // to avoid constant folding by the compiler, this field must *not* be final
019    public static String REQUESTED_API_VERSION = "2.0.99"; // !final
020
021    private ILoggerFactory loggerFactory;
022    private IMarkerFactory markerFactory;
023    private MDCAdapter mdcAdapter;
024
025    public Reload4jServiceProvider() {
026        try {
027            @SuppressWarnings("unused")
028            Level level = Level.TRACE;
029        } catch (NoSuchFieldError nsfe) {
030            Reporter.error("This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version");
031        }
032    }
033
034    @Override
035    public void initialize() {
036        loggerFactory = new Reload4jLoggerFactory();
037        markerFactory = new BasicMarkerFactory();
038        mdcAdapter = new Reload4jMDCAdapter();
039    }
040
041    @Override
042    public ILoggerFactory getLoggerFactory() {
043        return loggerFactory;
044    }
045
046
047    @Override
048    public IMarkerFactory getMarkerFactory() {
049        return markerFactory;
050    }
051
052
053    @Override
054    public MDCAdapter getMDCAdapter() {
055        return mdcAdapter;
056    }
057
058    @Override
059    public String getRequestedApiVersion() {
060        return REQUESTED_API_VERSION;
061    }
062}