本文整理汇总了Java中org.slf4j.impl.SimpleLogger类的典型用法代码示例。如果您正苦于以下问题:Java SimpleLogger类的具体用法?Java SimpleLogger怎么用?Java SimpleLogger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleLogger类属于org.slf4j.impl包,在下文中一共展示了SimpleLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addConsoleDebug
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
/**
* Adds a little (not complete) console debug output to a mocked logger.
*
* @param mogger
* the mocked logger
*/
public static void addConsoleDebug(SimpleLogger mogger) {
Answer<Void> answer = new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Object[] arguments = invocation.getArguments();
if (arguments != null && arguments.length > 0
&& arguments[0] != null) {
System.out.println(arguments[0]);
}
return null;
}
};
Mockito.doAnswer(answer).when(mogger).debug(Matchers.anyString());
Mockito.doAnswer(answer).when(mogger).debug(Matchers.anyString(),
Matchers.any(Throwable.class));
}
示例2: install
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
public static void install()
{
setDefaultProperty(SimpleLogger.SHOW_THREAD_NAME_KEY, Boolean.FALSE.toString());
setDefaultProperty(SimpleLogger.LEVEL_IN_BRACKETS_KEY, Boolean.TRUE.toString());
setDefaultProperty(SimpleLogger.SHOW_LOG_NAME_KEY, Boolean.FALSE.toString());
// apply Maven log level to well known white-listed ivy loggers
String mavenClientLogLevel = getDefaultLogLevel();
for(String loggerName : INTERESTING_LOGGERS)
{
System.setProperty(SimpleLogger.LOG_KEY_PREFIX+loggerName, mavenClientLogLevel);
}
// only log errors from unspecific engine loggers!
System.setProperty(SimpleLogger.LOG_KEY_PREFIX+IVY_PREFIX, Level.ERROR);
//Disable CXF warning at startup (missing META-INF/cxf/cxf.xml)
System.setProperty(SimpleLogger.LOG_KEY_PREFIX+"org.apache.cxf.bus.spring", Level.ERROR);
// only warnings from any logger used by ivy third parties (e.g. org.apache.myfaces.xxx, org.apache.cxf, ...)
System.setProperty(DEFAULT_LOG_LEVEL, Level.WARNING);
}
示例3: beforeAllTest
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
@BeforeClass
public static void beforeAllTest() throws Exception {
System.out.flush();
out = TeeInMemoryStringPrintStream.teeTo(System.out);
System.setOut(out);
System.err.flush();
err = TeeInMemoryStringPrintStream.teeTo(System.err);
System.setErr(err);
simpleLoggerOutField = SimpleLogger.class.getDeclaredField("TARGET_STREAM");
simpleLoggerOutField.setAccessible(true);
simpleLoggerPrintStream = (PrintStream) simpleLoggerOutField.get(null);
simpleLoggerPrintStream.flush();
simpleLoggerOutField.set(null, err); // Using the default configuration, SimpleLogger will use the err. Either way, we are going to reset to the original value after this set of tests
}
示例4: starting
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
@Override
public void starting(Description description) {
if (FirebaseApp.getApps().isEmpty()) {
final GoogleCredentials credentials;
try {
credentials = GoogleCredentials.fromStream(new FileInputStream(SERVICE_ACCOUNT_CREDENTIALS));
} catch (IOException e) {
throw new RuntimeException(e);
}
FirebaseOptions firebaseOptions = new FirebaseOptions.Builder()
.setDatabaseUrl(databaseUrl)
.setCredentials(credentials)
.build();
FirebaseApp.initializeApp(firebaseOptions);
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
}
this.databaseReference = FirebaseDatabase.getInstance().getReferenceFromUrl(databaseUrl);
}
示例5: init
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
/** Performs App init, called only once by VisEditor. */
static void init () {
if (initialized) throw new IllegalStateException("App cannot be initialized twice!");
new File(APP_FOLDER_PATH).mkdir();
Log.init();
//com.esotericsoftware.minlog.Log.TRACE();
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "ERROR");
checkCharset();
try {
buildTimestamp = readTimestamp();
if (buildTimestamp == null || buildTimestamp.equals("not built using CI")) {
buildTimestamp = "not built using CI";
buildTimestampValid = false;
} else
buildTimestampValid = true;
} catch (IOException e) {
Log.exception(e);
}
Log.info("Build: " + App.buildTimestamp);
initialized = true;
}
示例6: main
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
System.err.println("\nWelcome to WaveTact!\n");
System.setProperty(SimpleLogger.SHOW_DATE_TIME_KEY, "true");
System.setProperty(SimpleLogger.DATE_TIME_FORMAT_KEY, "[yyyy/MM/dd HH:mm:ss]");
System.setProperty(SimpleLogger.LEVEL_IN_BRACKETS_KEY, "true");
if(args.length == 1 && args[0].equalsIgnoreCase("--windowsdev")){
load(true);
}else{
if ((args.length >= 1) && args[0].equalsIgnoreCase("--client")) {
ConsoleClient.go();
} else if (new File("./console.unixsocket").exists()) {
System.err.println("Instance already started");
System.exit(0);
} else {
load(false);
}
}
}
示例7: setupLogging
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
private void setupLogging() {
if (verbosityLevel <= 0) {
// Verbosity is INFO or OFF, we hide the thread and logger names
System.setProperty(SimpleLogger.SHOW_THREAD_NAME_KEY, "false");
System.setProperty(SimpleLogger.SHOW_LOG_NAME_KEY, "false");
}
String level;
switch (verbosityLevel) {
case -1:
level = "OFF";
break;
case 1:
level = "DEBUG";
break;
case 2:
level = "TRACE";
break;
default:
level = "INFO";
break;
}
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, level);
LOGGER = LoggerFactory.getLogger(Main.class);
LOGGER.debug("Log Level: {}", level);
}
示例8: main
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
public static void main(String[] args) {
System.setProperty(SimpleLogger.ROOT_LOGGER_NAME, "PocketServer");
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "debug");
System.setProperty(SimpleLogger.LEVEL_IN_BRACKETS_KEY, "true");
System.setProperty(SimpleLogger.SHOW_THREAD_NAME_KEY, "false");
System.setProperty(SimpleLogger.SHOW_DATE_TIME_KEY, "false");
PocketServer server = new PocketServer();
while (true) {
}
}
示例9: setSlf4jTargetStream
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
public static void setSlf4jTargetStream(Class<?> clazz, PrintStream stream)
{
SimpleLogger simpleLogger = (SimpleLogger) LoggerFactory.getLogger(clazz);
try {
Field field = clazz.getClassLoader().loadClass("org.slf4j.impl.SimpleLogger").getDeclaredField("TARGET_STREAM");
field.setAccessible(true);
field.set(simpleLogger, stream);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
示例10: setSlf4jLogLevel
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
public static void setSlf4jLogLevel(Class<?> clazz, int logLevel)
{
SimpleLogger simpleLogger = (SimpleLogger) LoggerFactory.getLogger(clazz);
try {
Field field = clazz.getClassLoader().loadClass("org.slf4j.impl.SimpleLogger").getDeclaredField("currentLogLevel");
field.setAccessible(true);
field.setInt(simpleLogger, logLevel);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
示例11: reset
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
public static void reset()
{
for(String loggerName : INTERESTING_LOGGERS)
{
System.clearProperty(SimpleLogger.LOG_KEY_PREFIX+loggerName);
}
System.clearProperty(SimpleLogger.LOG_KEY_PREFIX+IVY_PREFIX);
}
示例12: mainInternal
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
protected static int mainInternal(String... args) {
CommandMain mainCommand = new CommandMain();
CommandPomMergeDriver mergeCommand = new CommandPomMergeDriver();
CommandPomVersionReplacer versionReplacerCommand = new CommandPomVersionReplacer();
JCommander jc = new JCommander(mainCommand);
jc.addCommand("merge", mergeCommand);
jc.addCommand("replace", versionReplacerCommand);
try {
jc.parse(args);
} catch (ParameterException e) {
System.err.println(e.getMessage());
return 1;
}
String logLevel = mainCommand.isDebug() ? "debug" : "error";
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, logLevel);
logger = LoggerFactory.getLogger(Main.class);
if (logger.isInfoEnabled()) {
logger.info("PomUtils version {}", ManifestUtils.getImplementationVersion());
}
if ("merge".equals(jc.getParsedCommand())) {
return executePomMergeDriver(mergeCommand);
} else if ("replace".equals(jc.getParsedCommand())) {
executePomVersionReplacer(versionReplacerCommand);
return 0;
}
jc.usage();
return 1;
}
示例13: config
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
public static void config() {
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, DEBUG);
setLogLevel("org.eclipse.jetty", WARN);
setLogLevel("org.raml.parser", WARN);
setLogLevel("org.apache.http", WARN);
setLogLevel("guru.nidi.ramlproxy.jetty.JettyProxyServlet", INFO);
LoggerFactory.getILoggerFactory();
}
示例14: before
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
@Before
public void before()
{
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
}
示例15: setUpClass
import org.slf4j.impl.SimpleLogger; //导入依赖的package包/类
@BeforeClass
public static void setUpClass(){
System.setProperty(SimpleLogger.LOG_FILE_KEY, "System.err");
}