use of ch.qos.logback.classic.Logger in project spring-boot by spring-projects.
the class LogbackLoggingSystemTests method testBasicConfigLocation.
@Test
public void testBasicConfigLocation() throws Exception {
this.loggingSystem.beforeInitialize();
ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory();
LoggerContext context = (LoggerContext) factory;
Logger root = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
assertThat(root.getAppender("CONSOLE")).isNotNull();
}
use of ch.qos.logback.classic.Logger in project sakuli by ConSol.
the class LoggerInitializerTest method testInitLoggerContextFromIncludeFolder.
@Test
public void testInitLoggerContextFromIncludeFolder() throws Throwable {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger root = context.getLogger("root");
Logger sakuliLogger = context.getLogger("org.sakuli");
Appender<ILoggingEvent> stdout = root.getAppender("stdout");
Appender<ILoggingEvent> sakuliAppender = root.getAppender("sakuli");
//no log config in classpath
Assert.assertNull(stdout);
Assert.assertNull(sakuliAppender);
Assert.assertNotNull(sakuliLogger);
Assert.assertNotNull(root);
when(sakuliProperties.getConfigFolder()).thenReturn(Paths.get(BaseTest.SAKULI_HOME_FOLDER_PATH + SakuliProperties.CONFIG_FOLDER_APPEDER));
testling.initLoggerContext();
verify(testling).getConfigFileFromClasspath();
verify(testling).getConfigFile();
//verify root logger
context = (LoggerContext) LoggerFactory.getILoggerFactory();
root = context.getLogger("root");
sakuliLogger = context.getLogger("org.sakuli");
stdout = root.getAppender("stdout");
sakuliAppender = root.getAppender("sakuli");
Assert.assertNotNull(stdout);
Assert.assertNotNull(sakuliLogger);
Assert.assertNotNull(sakuliAppender);
Assert.assertNotNull(sakuliAppender);
}
use of ch.qos.logback.classic.Logger in project midpoint by Evolveum.
the class LoggingConfigurationManager method configure.
public static void configure(LoggingConfigurationType config, String version, OperationResult result) throws SchemaException {
OperationResult res = result.createSubresult(LoggingConfigurationManager.class.getName() + ".configure");
if (InternalsConfig.avoidLoggingChange) {
LOGGER.info("IGNORING change of logging configuration (current config version: {}, new version {}) because avoidLoggingChange=true", currentlyUsedVersion, version);
res.recordNotApplicableIfUnknown();
return;
}
if (currentlyUsedVersion != null) {
LOGGER.info("Applying logging configuration (currently applied version: {}, new version: {})", currentlyUsedVersion, version);
} else {
LOGGER.info("Applying logging configuration (version {})", version);
}
currentlyUsedVersion = version;
// JUL Bridge initialization was here. (SLF4JBridgeHandler)
// But it was moved to a later phase as suggested by http://jira.qos.ch/browse/LOGBACK-740
// Initialize JUL bridge
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
//Get current log configuration
LoggerContext lc = (LoggerContext) TraceManager.getILoggerFactory();
//Prepare configurator in current context
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
//Generate configuration file as string
String configXml = prepareConfiguration(config);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("New logging configuration:");
LOGGER.trace(configXml);
}
InputStream cis = new ByteArrayInputStream(configXml.getBytes());
LOGGER.info("Resetting current logging configuration");
lc.getStatusManager().clear();
//Set all loggers to error
for (Logger l : lc.getLoggerList()) {
LOGGER.trace("Disable logger: {}", l);
l.setLevel(Level.ERROR);
}
// Reset configuration
lc.reset();
//Switch to new logging configuration
lc.setName("MidPoint");
try {
configurator.doConfigure(cis);
LOGGER.info("New logging configuration applied");
} catch (JoranException e) {
System.out.println("Error during applying logging configuration: " + e.getMessage());
LOGGER.error("Error during applying logging configuration: " + e.getMessage(), e);
result.createSubresult("Applying logging configuration.").recordFatalError(e.getMessage(), e);
} catch (NumberFormatException e) {
System.out.println("Error during applying logging configuration: " + e.getMessage());
LOGGER.error("Error during applying logging configuration: " + e.getMessage(), e);
result.createSubresult("Applying logging configuration.").recordFatalError(e.getMessage(), e);
}
//Get messages if error occurred;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
StatusPrinter.setPrintStream(new PrintStream(baos));
StatusPrinter.print(lc);
String internalLog = null;
try {
internalLog = baos.toString("UTF8");
} catch (UnsupportedEncodingException e) {
// should never happen
LOGGER.error("Woops?", e);
}
if (!StringUtils.isEmpty(internalLog)) {
//Parse internal log
res.recordSuccess();
String[] internalLogLines = internalLog.split("\n");
for (int i = 0; i < internalLogLines.length; i++) {
if (internalLogLines[i].contains("|-ERROR"))
res.recordPartialError(internalLogLines[i]);
res.appendDetail(internalLogLines[i]);
}
LOGGER.trace("LogBack internal log:\n{}", internalLog);
} else {
res.recordSuccess();
}
// Initialize JUL bridge
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
return;
}
use of ch.qos.logback.classic.Logger in project indy by Commonjava.
the class DiagnosticsManager method getDiagnosticBundle.
public File getDiagnosticBundle() throws IOException {
File out = File.createTempFile("indy-diags." + new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss.SSSZ").format(new Date()), ".zip");
org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
Logger rootLogger = (Logger) LoggerFactory.getLogger("ROOT");
logger.info("Writing diagnostic bundle to: '{}'", out);
Appender<ILoggingEvent> appender = rootLogger.getAppender(FILE_LOGGER);
if (appender != null && (appender instanceof FileAppender)) {
try (ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(out))) {
File dir = new File(((FileAppender) appender).getFile()).getParentFile();
for (File f : dir.listFiles(file -> file.getName().endsWith(".log"))) {
String name = LOGS_DIR + "/" + f.getName();
logger.info("Adding {} to bundle zip: {}", name, out);
zip.putNextEntry(new ZipEntry(name));
try (InputStream in = new FileInputStream(f)) {
IOUtils.copy(in, zip);
}
}
logger.info("Adding thread dump to bundle zip: {}", out);
zip.putNextEntry(new ZipEntry(THREAD_DUMP_FILE));
zip.write(getThreadDumpString().getBytes());
zip.flush();
zip.close();
}
} else {
return null;
}
return out;
}
use of ch.qos.logback.classic.Logger in project Alpha by alpha-asp.
the class MainTest method testLargeInputProgram.
@Test
@Ignore
public void testLargeInputProgram() {
Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.DEBUG);
//main(new String[]{"-g", "naive", "-s", "default", "-n", "2", "-i", "./benchmarks/omiga/omiga-testcases/locstrat/locstrat-200.txt"});
//main(new String[]{"-g", "naive", "-s", "default", "-n", "2", "-i", "./benchmarks/omiga/omiga-testcases/cutedge/cutedge-100-50.txt"});
//main(new String[]{"-g", "naive", "-s", "default", "-n", "10", "-i", "./benchmarks/omiga/omiga-testcases/3col/3col-20-38.txt"});
//main(new String[]{"-g", "naive", "-s", "naive", "-n", "10", "-i", "./benchmarks/omiga/omiga-testcases/reach/reach-1.txt"});
main(new String[] { "-g", "naive", "-s", "default", "-n", "1", "-i", "./benchmarks/siemens/vehicle_normal_small.asp" });
}
Aggregations