use of org.apache.logging.log4j.core.Logger in project logging-log4j2 by apache.
the class CsvParameterLayoutAllAsyncTest method testLayoutDefaultNormal.
@Test
public void testLayoutDefaultNormal() throws Exception {
final Logger root = (Logger) LogManager.getRootLogger();
CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), false);
}
use of org.apache.logging.log4j.core.Logger in project hive by apache.
the class HttpServer method getLogDir.
String getLogDir(Configuration conf) {
String logDir = conf.get("hive.log.dir");
if (logDir == null) {
logDir = System.getProperty("hive.log.dir");
}
if (logDir != null) {
return logDir;
}
LoggerContext context = (LoggerContext) LogManager.getContext(false);
for (Logger logger : context.getLoggers()) {
for (Appender appender : logger.getAppenders().values()) {
if (appender instanceof AbstractOutputStreamAppender) {
OutputStreamManager manager = ((AbstractOutputStreamAppender<?>) appender).getManager();
if (manager instanceof FileManager) {
String fileName = ((FileManager) manager).getFileName();
if (fileName != null) {
return fileName.substring(0, fileName.lastIndexOf('/'));
}
}
}
}
}
return null;
}
use of org.apache.logging.log4j.core.Logger in project HikariCP by brettwooldridge.
the class TestElf method setSlf4jLogLevel.
static void setSlf4jLogLevel(Class<?> clazz, Level logLevel) {
try {
Log4jLogger log4Jlogger = (Log4jLogger) LoggerFactory.getLogger(clazz);
Field field = clazz.getClassLoader().loadClass("org.apache.logging.slf4j.Log4jLogger").getDeclaredField("logger");
field.setAccessible(true);
Logger logger = (Logger) field.get(log4Jlogger);
logger.setLevel(logLevel);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.logging.log4j.core.Logger in project metrics by dropwizard.
the class InstrumentedAppenderConfigTest method canRecordAll.
// The biggest test is that we can initialize the log4j2 config at all.
@Test
public void canRecordAll() throws Exception {
Logger logger = context.getLogger(this.getClass().getName());
long initialAllCount = registry.meter(METRIC_NAME_PREFIX + ".all").getCount();
logger.error("an error message");
assertThat(registry.meter(METRIC_NAME_PREFIX + ".all").getCount()).isEqualTo(initialAllCount + 1);
}
use of org.apache.logging.log4j.core.Logger in project metrics by dropwizard.
the class InstrumentedAppenderConfigTest method noInvalidRecording.
@Test
public void noInvalidRecording() throws Exception {
Logger logger = context.getLogger(this.getClass().getName());
long initialInfoCount = registry.meter(METRIC_NAME_PREFIX + ".info").getCount();
logger.error("an error message");
assertThat(registry.meter(METRIC_NAME_PREFIX + ".info").getCount()).isEqualTo(initialInfoCount);
}
Aggregations