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 // LoggerFactory expects providers to initialize markerFactory as early as possible. 021 private final IMarkerFactory markerFactory; 022 // LoggerFactory expects providers to initialize their MDCAdapter field 023 // as early as possible, preferably at construction time. 024 private final MDCAdapter mdcAdapter; 025 026 public JULServiceProvider() { 027 markerFactory = new BasicMarkerFactory(); 028 mdcAdapter = new BasicMDCAdapter(); 029 } 030 031 @Override 032 public ILoggerFactory getLoggerFactory() { 033 return loggerFactory; 034 } 035 036 @Override 037 public IMarkerFactory getMarkerFactory() { 038 return markerFactory; 039 } 040 041 public MDCAdapter getMDCAdapter() { 042 return mdcAdapter; 043 } 044 045 @Override 046 public String getRequestedApiVersion() { 047 return REQUESTED_API_VERSION; 048 } 049 050 @Override 051 public void initialize() { 052 loggerFactory = new JDK14LoggerFactory(); 053 } 054}