mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-25 22:36:20 +00:00
parent
6c4108b38a
commit
9f60dc7578
@ -66,9 +66,15 @@ public abstract class ESLoggerFactory {
|
|||||||
return defaultFactory.newInstance(name.intern());
|
return defaultFactory.newInstance(name.intern());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ESLogger getRootLogger() {
|
||||||
|
return defaultFactory.rootLogger();
|
||||||
|
}
|
||||||
|
|
||||||
public ESLogger newInstance(String name) {
|
public ESLogger newInstance(String name) {
|
||||||
return newInstance(null, name);
|
return newInstance(null, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract ESLogger rootLogger();
|
||||||
|
|
||||||
protected abstract ESLogger newInstance(String prefix, String name);
|
protected abstract ESLogger newInstance(String prefix, String name);
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,18 @@ package org.elasticsearch.common.logging.jdk;
|
|||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||||
|
|
||||||
|
import java.util.logging.LogManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class JdkESLoggerFactory extends ESLoggerFactory {
|
public class JdkESLoggerFactory extends ESLoggerFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ESLogger rootLogger() {
|
||||||
|
return getLogger("");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ESLogger newInstance(String prefix, String name) {
|
protected ESLogger newInstance(String prefix, String name) {
|
||||||
final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(name);
|
final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(name);
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package org.elasticsearch.common.logging.log4j;
|
package org.elasticsearch.common.logging.log4j;
|
||||||
|
|
||||||
|
import org.apache.log4j.LogManager;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||||
|
|
||||||
@ -27,6 +29,11 @@ import org.elasticsearch.common.logging.ESLoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class Log4jESLoggerFactory extends ESLoggerFactory {
|
public class Log4jESLoggerFactory extends ESLoggerFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ESLogger rootLogger() {
|
||||||
|
return new Log4jESLogger(null, Logger.getRootLogger());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ESLogger newInstance(String prefix, String name) {
|
protected ESLogger newInstance(String prefix, String name) {
|
||||||
final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(name);
|
final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(name);
|
||||||
|
@ -21,6 +21,7 @@ package org.elasticsearch.common.logging.slf4j;
|
|||||||
|
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||||
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,6 +29,11 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class Slf4jESLoggerFactory extends ESLoggerFactory {
|
public class Slf4jESLoggerFactory extends ESLoggerFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ESLogger rootLogger() {
|
||||||
|
return getLogger(Logger.ROOT_LOGGER_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ESLogger newInstance(String prefix, String name) {
|
protected ESLogger newInstance(String prefix, String name) {
|
||||||
return new Slf4jESLogger(prefix, LoggerFactory.getLogger(name));
|
return new Slf4jESLogger(prefix, LoggerFactory.getLogger(name));
|
||||||
|
@ -79,7 +79,11 @@ public class NodeSettingsService extends AbstractComponent implements ClusterSta
|
|||||||
for (Map.Entry<String, String> entry : event.state().metaData().settings().getAsMap().entrySet()) {
|
for (Map.Entry<String, String> entry : event.state().metaData().settings().getAsMap().entrySet()) {
|
||||||
if (entry.getKey().startsWith("logger.")) {
|
if (entry.getKey().startsWith("logger.")) {
|
||||||
String component = entry.getKey().substring("logger.".length());
|
String component = entry.getKey().substring("logger.".length());
|
||||||
ESLoggerFactory.getLogger(component).setLevel(entry.getValue());
|
if ("_root".equals(component)) {
|
||||||
|
ESLoggerFactory.getRootLogger().setLevel(entry.getValue());
|
||||||
|
} else {
|
||||||
|
ESLoggerFactory.getLogger(component).setLevel(entry.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user