本文整理汇总了Java中ch.qos.logback.core.status.WarnStatus类的典型用法代码示例。如果您正苦于以下问题:Java WarnStatus类的具体用法?Java WarnStatus怎么用?Java WarnStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WarnStatus类属于ch.qos.logback.core.status包,在下文中一共展示了WarnStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: multiplicityWarning
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
private void multiplicityWarning(String resourceName, ClassLoader classLoader) {
Set urlSet = null;
StatusManager sm = this.loggerContext.getStatusManager();
try {
urlSet = Loader.getResourceOccurrenceCount(resourceName, classLoader);
} catch (IOException var7) {
sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]", this.loggerContext, var7));
}
if (urlSet != null && urlSet.size() > 1) {
sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.", this.loggerContext));
Iterator i$ = urlSet.iterator();
while (i$.hasNext()) {
URL url = (URL) i$.next();
sm.add(new WarnStatus("Resource [" + resourceName + "] occurs at [" + url.toString() + "]", this.loggerContext));
}
}
}
示例2: findConfigFileURL
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
private URL findConfigFileURL(Context ctx, LoggerContext loggerContext) {
StatusManager sm = loggerContext.getStatusManager();
String jndiEntryForConfigResource = JNDIUtil.lookup(ctx,
JNDI_CONFIGURATION_RESOURCE);
// Do we have a dedicated configuration file?
if (jndiEntryForConfigResource != null) {
sm.add(new InfoStatus("Searching for [" + jndiEntryForConfigResource
+ "]", this));
URL url = urlByResourceName(sm, jndiEntryForConfigResource);
if (url == null) {
String msg = "The jndi resource [" + jndiEntryForConfigResource
+ "] for context [" + loggerContext.getName()
+ "] does not lead to a valid file";
sm.add(new WarnStatus(msg, this));
}
return url;
} else {
String resourceByConvention = conventionalConfigFileName(loggerContext
.getName());
return urlByResourceName(sm, resourceByConvention);
}
}
示例3: multiplicityWarning
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
private void multiplicityWarning(String resourceName, ClassLoader classLoader) {
Set<URL> urlSet = null;
StatusManager sm = loggerContext.getStatusManager();
try {
urlSet = Loader.getResourceOccurrenceCount(resourceName, classLoader);
} catch (IOException e) {
sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]",
loggerContext, e));
}
if (urlSet != null && urlSet.size() > 1) {
sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.",
loggerContext));
for (URL url : urlSet) {
sm.add(new WarnStatus("Resource [" + resourceName + "] occurs at [" + url.toString() + "]",
loggerContext));
}
}
}
示例4: start
import ch.qos.logback.core.status.WarnStatus; //导入依赖的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());
}
}
示例5: start
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
@Override
public synchronized void start() {
if (isStarted()) {
return;
}
if (layout == null) {
layout = new EchoLayout<>();
addStatus(new WarnStatus("No layout, default to " + layout, this));
}
if (logGroupName == null) {
logGroupName = getClass().getSimpleName();
addStatus(new WarnStatus("No logGroupName, default to " + logGroupName, this));
}
if (logStreamName == null) {
logStreamName = new SimpleDateFormat("yyyyMMdd'T'HHmmss").format(new Date());
addStatus(new WarnStatus("No logGroupName, default to " + logStreamName, this));
}
try {
if (awsLogs == null) {
awsLogs = AWSLogsClientBuilder.defaultClient();
}
createLogGroup();
createLogStream();
} catch (final AmazonClientException e) {
awsLogs = null;
addStatus(new ErrorStatus(e.getMessage(), this, e));
}
// Start a new daemon time thread to periodically upload events
// Because this is a deamon thread, it will not block shutdown
new DaemonTimerThread().start();
// Add a shutdown hook to catch any final events at shutdown
Runtime.getRuntime().addShutdownHook(new ShutdownHook());
layout.start();
super.start();
}
示例6: doAppend
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
public synchronized void doAppend(E eventObject) {
// WARNING: The guard check MUST be the first statement in the
// doAppend() method.
// prevent re-entry.
if (guard) {
return;
}
try {
guard = true;
if (!this.started) {
if (statusRepeatCount++ < ALLOWED_REPEATS) {
addStatus(new WarnStatus(
"Attempted to append to non started appender [" + name + "].",
this));
}
return;
}
if (getFilterChainDecision(eventObject) == FilterReply.DENY) {
return;
}
// ok, we now invoke derived class' implementation of append
this.append(eventObject);
} catch (Exception e) {
if (exceptionCount++ < ALLOWED_REPEATS) {
addError("Appender [" + name + "] failed to append.", e);
}
} finally {
guard = false;
}
}
示例7: targetWarn
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
private void targetWarn(String val) {
Status status = new WarnStatus("[" + val + "] should be one of "
+ Arrays.toString(ConsoleTarget.values()), this);
status.add(new WarnStatus(
"Using previously set target, System.out by default.", this));
addStatus(status);
}
示例8: doAppend
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
public void doAppend(E eventObject) {
// WARNING: The guard check MUST be the first statement in the
// doAppend() method.
// prevent re-entry.
if (Boolean.TRUE.equals(guard.get())) {
return;
}
try {
guard.set(Boolean.TRUE);
if (!this.started) {
if (statusRepeatCount++ < ALLOWED_REPEATS) {
addStatus(new WarnStatus(
"Attempted to append to non started appender [" + name + "].",
this));
}
return;
}
if (getFilterChainDecision(eventObject) == FilterReply.DENY) {
return;
}
// ok, we now invoke derived class' implementation of append
this.append(eventObject);
} catch (Exception e) {
if (exceptionCount++ < ALLOWED_REPEATS) {
addError("Appender [" + name + "] failed to append.", e);
}
} finally {
guard.set(Boolean.FALSE);
}
}
示例9: testNested
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
@Test
public void testNested() {
Status s0 = new ErrorStatus("test0", this);
Status s1 = new InfoStatus("test1", this);
Status s11 = new InfoStatus("test11", this);
Status s12 = new InfoStatus("test12", this);
s1.add(s11);
s1.add(s12);
Status s2 = new InfoStatus("test2", this);
Status s21 = new InfoStatus("test21", this);
Status s211 = new WarnStatus("test211", this);
Status s22 = new InfoStatus("test22", this);
s2.add(s21);
s2.add(s22);
s21.add(s211);
Context context = new ContextBase();
context.getStatusManager().add(s0);
context.getStatusManager().add(s1);
context.getStatusManager().add(s2);
StatusPrinter.print(context);
String result = outputStream.toString();
assertTrue(result.contains("+ INFO in "+this.getClass().getName()));
assertTrue(result.contains("+ WARN in "+this.getClass().getName()));
assertTrue(result.contains(" |-WARN in "+this.getClass().getName()));
}
示例10: testWithException
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
@Test
public void testWithException() {
Status s0 = new ErrorStatus("test0", this);
Status s1 = new InfoStatus("test1", this, new Exception("testEx"));
Status s11 = new InfoStatus("test11", this);
Status s12 = new InfoStatus("test12", this);
s1.add(s11);
s1.add(s12);
Status s2 = new InfoStatus("test2", this);
Status s21 = new InfoStatus("test21", this);
Status s211 = new WarnStatus("test211", this);
Status s22 = new InfoStatus("test22", this);
s2.add(s21);
s2.add(s22);
s21.add(s211);
Context context = new ContextBase();
context.getStatusManager().add(s0);
context.getStatusManager().add(s1);
context.getStatusManager().add(s2);
StatusPrinter.print(context);
String result = outputStream.toString();
assertTrue(result.contains("|-ERROR in "+this.getClass().getName()));
assertTrue(result.contains("+ INFO in "+this.getClass().getName()));
assertTrue(result.contains("ch.qos.logback.core.util.StatusPrinterTest.testWithException"));
}
示例11: noAppenderDefinedWarning
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
final void noAppenderDefinedWarning(final Logger logger) {
if (noAppenderWarning++ == 0) {
getStatusManager().add(
new WarnStatus("No appenders present in context [" + getName()
+ "] for logger [" + logger.getName() + "].", logger));
}
}
示例12: setTarget
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
public void setTarget(String target)
{
if(!(target.equals("System.out") || target.equals("System.err")))
{
Status status = new WarnStatus("[" + target + "] should be one of System.out or System.err", this);
status.add(new WarnStatus("Using default target System.out", this));
addStatus(status);
return;
}
this.target = target;
}
示例13: noAppenderDefinedWarning
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
final void noAppenderDefinedWarning(KonkerLogger logger) {
if(this.noAppenderWarning++ == 0) {
this.getStatusManager().add(new WarnStatus("No appenders present in context [" + this.getName() + "] for logger [" + logger.getName() + "].", logger));
}
}
示例14: addWarn
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
public void addWarn(String msg) {
addStatus(new WarnStatus(msg, getOrigin()));
}
示例15: addWarn
import ch.qos.logback.core.status.WarnStatus; //导入依赖的package包/类
public void addWarn(String msg) {
addStatus(new WarnStatus(msg, getDeclaredOrigin()));
}