use of ch.qos.logback.core.Context in project cdap by caskdata.
the class LogPipelineLoader method setupPipelineCConf.
/**
* Copies overridable configurations from the pipeline configuration into the given {@link CConfiguration}.
*/
private CConfiguration setupPipelineCConf(JoranConfigurator configurator, CConfiguration cConf) {
Context context = configurator.getContext();
// The list of properties that can be overridden per pipeline configuration
Set<String> keys = ImmutableSet.of(Constants.Logging.PIPELINE_BUFFER_SIZE, Constants.Logging.PIPELINE_EVENT_DELAY_MS, Constants.Logging.PIPELINE_KAFKA_FETCH_SIZE, Constants.Logging.PIPELINE_CHECKPOINT_INTERVAL_MS, Constants.Logging.PIPELINE_LOGGER_CACHE_SIZE, Constants.Logging.PIPELINE_LOGGER_CACHE_EXPIRATION_MS);
// defined in the logback xml.
for (String key : keys) {
context.putProperty(key, cConf.get(key));
cConf.set(key, configurator.getExecutionContext().subst("${" + key + "}"));
}
return cConf;
}
use of ch.qos.logback.core.Context in project OpenClinica by OpenClinica.
the class LoggerStartupListener method start.
@Override
public void start() {
if (started)
return;
Context context = getContext();
if (resourceLoader == null)
resourceLoader = new DefaultResourceLoader();
try {
webapp = getWebAppName(resourceLoader.getResource("/").getURI().getPath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
DATAINFO = loadProperties("datainfo.properties");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
getPropertiesSource();
context.putProperty("log.dir", getField("log.dir"));
context.putProperty("logLocation", getField("logLocation"));
context.putProperty("logLevel", getField("logLevel"));
context.putProperty("hibernateSQLLogLevel", getField("hibernateSQLLogLevel"));
context.putProperty("hibernateTypeLogLevel", getField("hibernateTypeLogLevel"));
started = true;
}
use of ch.qos.logback.core.Context in project cdap by caskdata.
the class ProgramRunners method createLogbackJar.
/**
* Creates a jar that contains a logback.xml configured for the current process
*
* @param targetLocation the jar location
* @return the {@link Location} where the jar was created to or {@code null} if "logback.xml" is not found
* in the current ClassLoader.
* @throws IOException if failed in reading the logback xml or writing out the jar
*/
@Nullable
public static Location createLogbackJar(Location targetLocation) throws IOException {
ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
if (!(loggerFactory instanceof Context)) {
return null;
}
URL logbackURL = ConfigurationWatchListUtil.getMainWatchURL((Context) loggerFactory);
if (logbackURL == null) {
return null;
}
try (InputStream input = logbackURL.openStream()) {
try (JarOutputStream output = new JarOutputStream(targetLocation.getOutputStream())) {
output.putNextEntry(new JarEntry("logback.xml"));
ByteStreams.copy(input, output);
}
return targetLocation;
}
}
Aggregations