forked from mindspore-Ecosystem/mindspore
java and jni log only print on screen
This commit is contained in:
parent
ee27e2b7d5
commit
09c459ab39
|
@ -48,12 +48,3 @@ std::string RealPath(const char *path) {
|
|||
return res;
|
||||
}
|
||||
|
||||
#if defined(USE_GLOG) || defined(BUILD_CORE_RUNTIME)
|
||||
extern "C" {
|
||||
extern void mindspore_log_init();
|
||||
}
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
mindspore_log_init();
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
package com.mindspore.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.SimpleFormatter;
|
||||
|
||||
public final class MindsporeLite {
|
||||
private static final Object lock = new Object();
|
||||
|
@ -14,26 +9,8 @@ public final class MindsporeLite {
|
|||
public static Logger GetLogger() {
|
||||
if (LOGGER == null) {
|
||||
synchronized (lock) {
|
||||
if (LOGGER != null) {
|
||||
return LOGGER;
|
||||
}
|
||||
LOGGER = Logger.getLogger(MindsporeLite.class.toString());
|
||||
String logtostderr = System.getenv("GLOG_logtostderr");
|
||||
if ("0".equals(logtostderr)) {
|
||||
String GLOG_log_dir = System.getenv("GLOG_log_dir");
|
||||
if (GLOG_log_dir != null && !"".equals(GLOG_log_dir)) {
|
||||
FileHandler fileHandler = null;
|
||||
try {
|
||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("uuuuMMdd-HHmmss.SSSS");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
fileHandler = new FileHandler(GLOG_log_dir + "/MinsSporeLite.java_log." + dtf.format(now) + ".log");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SimpleFormatter formatter = new SimpleFormatter();
|
||||
fileHandler.setFormatter(formatter);
|
||||
LOGGER.addHandler(fileHandler);
|
||||
}
|
||||
if (LOGGER == null) {
|
||||
LOGGER = Logger.getLogger(MindsporeLite.class.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue