本文整理汇总了Java中ch.qos.logback.core.joran.spi.JoranException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java JoranException.printStackTrace方法的具体用法?Java JoranException.printStackTrace怎么用?Java JoranException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.core.joran.spi.JoranException
的用法示例。
在下文中一共展示了JoranException.printStackTrace方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeLogback
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
@PostConstruct
public void initializeLogback() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
InputStream is = InitLogback.class.getClassLoader().getResourceAsStream("tasfe-logback.xml");
if (is == null)
return;
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
try {
configurator.doConfigure(is);
} catch (JoranException e) {
e.printStackTrace();
}
}
示例2: initializeLogging
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
private void initializeLogging() {
String graviteeHome = System.getProperty("gravitee.home");
String logbackConfiguration = graviteeHome + File.separator + "config" + File.separator + "logback.xml";
File logbackConfigurationfile = new File(logbackConfiguration);
// If logback configuration available, load it, else, load default logback configuration
if (logbackConfigurationfile.exists()) {
System.setProperty("logback.configurationFile", logbackConfigurationfile.getAbsolutePath());
StaticLoggerBinder loggerBinder = StaticLoggerBinder.getSingleton();
LoggerContext loggerContext = (LoggerContext) loggerBinder.getLoggerFactory();
loggerContext.reset();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(loggerContext);
try {
configurator.doConfigure(logbackConfigurationfile);
} catch( JoranException e ) {
e.printStackTrace();
}
// Internal status data is printed in case of warnings or errors.
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
}
}
示例3: buildFruit
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
public Fruit buildFruit() {
Context context = new ContextBase();
this.fruit = null;
context.putProperty("fruitKey", "orange-"+count);
// for next round
count++;
FruitConfigurator fruitConfigurator = new FruitConfigurator(this);
fruitConfigurator.setContext(context);
try {
fruitConfigurator.doConfigure(eventList);
} catch(JoranException je) {
je.printStackTrace();
}
return fruit;
}
示例4: start
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
public void start(BundleContext context) {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
// the context was probably already configured by default configuration
// rules
lc.reset();
configurator.doConfigure("src/test/input/osgi/simple.xml");
} catch (JoranException je) {
je.printStackTrace();
}
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
Logger logger = LoggerFactory.getLogger(this.getClass());
logger.info("Activator.start()");
m_context = context;
}
示例5: main
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
Logger logger = (Logger) LoggerFactory.getLogger(ConfigurationTester.class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(args[0]);
} catch (JoranException je) {
je.printStackTrace();
}
// After we've called Joran, let's print information about the
// internal status of logback
StatusPrinter.print(lc);
logger.debug("**Hello {}", new Bar());
MDC.put("testKey", "testValueFromMDC");
MDC.put("testKey2", "value2");
for (int i = 0; i < 10; i++) {
logger.debug("logging statement " + i);
Thread.sleep(100);
}
Bar bar = new Bar();
bar.createLoggingRequest();
}
示例6: start
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
@Override
public void start() throws LifecycleException {
super.start();
ctx.start();
if (filename == null) {
filename = OptionHelper.getSystemProperty("logbackAccess.configurationFile");
if (filename == null) {
filename = DEFAULT_CONFIG_FILE;
}
ctx.getStatusManager().add(new InfoStatus("filename property not set. Assuming [" + filename + "]", this));
}
// TODO: Support classpath config
File configFile = new File(filename);
if (configFile.exists()) {
try {
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(ctx);
jc.doConfigure(filename);
} catch (JoranException e) {
// TODO can we do better than printing a stack trace on syserr?
e.printStackTrace();
}
} else {
ctx.getStatusManager().add(new WarnStatus("[" + filename + "] does not exist", this));
}
if (!quiet) {
StatusPrinter.print(ctx.getStatusManager());
}
}
示例7: loggingConfigOff
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
private static void loggingConfigOff() {
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext((LoggerContext) LoggerFactory.getILoggerFactory());
((LoggerContext) LoggerFactory.getILoggerFactory()).reset();
configurator.doConfigure(App.class.getResourceAsStream("/logback-cli-off.xml"));
} catch (JoranException e) {
e.printStackTrace();
}
}
示例8: loggingConfigOn
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
private static void loggingConfigOn() {
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext((LoggerContext) LoggerFactory.getILoggerFactory());
((LoggerContext) LoggerFactory.getILoggerFactory()).reset();
configurator.doConfigure(App.class.getResourceAsStream("/logback-cli-on.xml"));
} catch (JoranException e) {
e.printStackTrace();
}
}
示例9: configureLogback
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
/**
* @param loggerFactory
* the logger factory context
* @param stream
* The input stream to be configured
*/
private static void configureLogback(final LoggerContext context, final InputStream stream) {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
try {
configurator.doConfigure(stream);
} catch (JoranException e) {
// not much we can do since logger may not be configured yet
e.printStackTrace(System.out);
}
}
示例10: loadLogFile
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
private static void loadLogFile() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
try {
configurator.doConfigure("src/test/resources/test-logback.xml");
} catch (JoranException e) {
e.printStackTrace();
}
}
示例11: main
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
public static void main(String[] args) {
if (args.length != 1) {
usage("Wrong number of arguments.");
}
String configFile = args[0];
if (configFile.endsWith(".xml")) {
try {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(args[0]);
} catch (JoranException je) {
je.printStackTrace();
}
}
NumberCruncherServer ncs;
try {
ncs = new NumberCruncherServer();
logger.info("Creating registry.");
Registry registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
registry.rebind("Factor", ncs);
logger.info("NumberCruncherServer bound and ready.");
} catch (Exception e) {
logger.error("Could not bind NumberCruncherServer.", e);
return;
}
}
示例12: main
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
if (args.length == 0) {
System.out.println("A configuration file must be passed as a parameter.");
return;
}
Logger logger = (Logger) LoggerFactory.getLogger(FilterEvents.class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(args[0]);
} catch (JoranException je) {
je.printStackTrace();
}
for (int i = 0; i < 10; i++) {
if (i == 3) {
MDC.put("username", "sebastien");
logger.debug("logging statement {}", i);
MDC.remove("username");
} else if (i == 6) {
Marker billing = MarkerFactory.getMarker("billing");
logger.error(billing, "billing statement {}", i);
} else {
logger.info("logging statement {}", i);
}
}
}
示例13: configureWithPath
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
/**
* Reads configuration from the given file and loads it.
*/
private static void configureWithPath(String pathToConfig) {
if (!configured) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
context.reset();
configurator.doConfigure(pathToConfig);
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
uncaughtExceptionLogger.error("An error occurred in thread {}", t.getName(), e);
}
});
configured = true;
} catch (JoranException je) {
System.err.println("Unable to configure Logback");
je.printStackTrace();
}
} else {
throw new IllegalStateException("Logging has already been configured!");
}
}
示例14: startInternal
import ch.qos.logback.core.joran.spi.JoranException; //导入方法依赖的package包/类
@Override
public void startInternal() throws LifecycleException {
executorService = ExecutorServiceUtil.newExecutorService();
if (filename == null) {
String tomcatBaseProperty = OptionHelper
.getSystemProperty("catalina.base");
filename = tomcatBaseProperty + File.separatorChar + DEFAULT_CONFIG_FILE;
File baseConfigFile = new File(filename);
if (!baseConfigFile.exists()) {
String tomcatHomeProperty = OptionHelper
.getSystemProperty("catalina.home");
filename = tomcatHomeProperty + File.separatorChar
+ DEFAULT_CONFIG_FILE;
}
getStatusManager().add(
new InfoStatus("filename property not set. Assuming [" + filename
+ "]", this));
}
File configFile = new File(filename);
if (configFile.exists()) {
try {
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(this);
jc.doConfigure(filename);
} catch (JoranException e) {
// TODO can we do better than printing a stack trace on syserr?
e.printStackTrace();
}
} else {
getStatusManager().add(
new WarnStatus("[" + filename + "] does not exist", this));
}
if (!quiet) {
StatusPrinter.print(getStatusManager());
}
started = true;
setState(LifecycleState.STARTING);
}