本文整理汇总了Java中org.apache.log4j.AppenderSkeleton类的典型用法代码示例。如果您正苦于以下问题:Java AppenderSkeleton类的具体用法?Java AppenderSkeleton怎么用?Java AppenderSkeleton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppenderSkeleton类属于org.apache.log4j包,在下文中一共展示了AppenderSkeleton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EngineLogView
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
public EngineLogView() {
labelProvider = new EngineLogViewLabelProvider();
appender = new AppenderSkeleton() {
@Override
protected void append(LoggingEvent arg0) {
synchronized (this) {
this.notifyAll();
}
}
public void close() {
}
public boolean requiresLayout() {
return false;
}
};
}
示例2: setupLogger
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
/**
* Setup {@link org.apache.log4j.Logger}, the default logger implementation for tests,
* to append {@link LoggingEvent}s to {@link #loggingEvents} so that we can assert if
* the right messages were logged.
*
* @see #testLogTimeoutAlmostReachedWarningDuringCommit
* @see #testLogTimeoutAlmostReachedWarningDuringRecovery
*/
private void setupLogger() {
Logger.getRootLogger().removeAllAppenders();
logger = Logger.getLogger(TwoPhaseCommitSinkFunction.class);
testAppender = new AppenderSkeleton() {
@Override
protected void append(LoggingEvent event) {
loggingEvents.add(event);
}
@Override
public void close() {
}
@Override
public boolean requiresLayout() {
return false;
}
};
logger.addAppender(testAppender);
logger.setLevel(Level.WARN);
}
示例3: LogVerifier
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
public LogVerifier() {
this.appender = new AppenderSkeleton() {
@Override
public void close() {
}
@Override
public boolean requiresLayout() {
return false;
}
@Override
protected void append(LoggingEvent event) {
LogVerifier.this.append(event);
}
};
}
示例4: createAppenderProvider
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
@Override
public AppenderProvider createAppenderProvider(URI serverURI) throws LogForwardingException {
return new AppenderProvider() {
@Override
public Appender getAppender() throws LogForwardingException {
return new AppenderSkeleton() {
@Override
protected void append(LoggingEvent event) {
eventProcessor.processEvent(event);
}
@Override
public boolean requiresLayout() {
return false;
}
@Override
public void close() {
}
};
}
};
}
示例5: setUp
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
@Before
public void setUp()
throws SQLException, IOException, InterruptedException
{
Appender a = Logger.getRootLogger().getAppender("STDERR");
if (a instanceof AppenderSkeleton) {
((AppenderSkeleton)a).setThreshold(Level.DEBUG);
}
dbManager.cleanup();
servers.cleanup();
servers.start(serverArgs);
servers.waitUntilActive();
servers.createDatabaseA();
tr.startup();
log.info("######################################################################");
log.info("######################################################################");
log.info("setup done");
}
示例6: setUp
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
@Before
public void setUp()
throws SQLException, IOException, InterruptedException
{
log.info("######################################################################");
log.info("######################################################################");
log.info("setting up");
Appender a = Logger.getRootLogger().getAppender("STDERR");
if (a instanceof AppenderSkeleton) {
((AppenderSkeleton)a).setThreshold(Level.DEBUG);
}
log.info("######################################################################");
log.info("######################################################################");
log.info("setting up");
dbManager.cleanup();
tr.startup();
log.info("######################################################################");
log.info("######################################################################");
log.info("setup done");
}
示例7: setUp
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
@Before
public void setUp()
throws SQLException, IOException, InterruptedException
{
Appender a = Logger.getRootLogger().getAppender("STDERR");
if (a instanceof AppenderSkeleton) {
((AppenderSkeleton)a).setThreshold(Level.DEBUG);
}
dbManager.cleanup();
servers.cleanup();
servers.start();
servers.waitUntilActive();
servers.createDatabaseA();
tr.startup();
log.info("######################################################################");
log.info("######################################################################");
log.info("setup done");
}
示例8: setUp
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
/**
* Sets up.
*
* @throws Exception the exception
*/
@Before
public void setUp() throws Exception {
testling = createTestling(environment, enableServiceBrokerFake);
testAppender = new AppenderSkeleton() {
@Override
protected void append(final LoggingEvent loggingEvent) {
System.out.println("**** APPEND ****");
logMessage = loggingEvent.getMessage().toString();
}
@Override
public void close() {
}
@Override
public boolean requiresLayout() {
return false;
}
};
Logger.getLogger(testling.getClass()).setAdditivity(true);
Logger.getLogger(testling.getClass()).addAppender(testAppender);
}
示例9: initLogger
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
private static void initLogger(String filename) {
final String PATTERN = "[%d{yyyy-MM-dd HH:mm:ss}] [%-5p] [%c{1}] %m%n";
// Stores whether an error has occured
AppenderSkeleton errorFlagAppender = new ErrorFlagAppender();
errorFlagAppender.setThreshold(Level.ERROR);
errorFlagAppender.activateOptions();
org.apache.log4j.Logger.getRootLogger().addAppender(errorFlagAppender);
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.setEncoding("UTF-8");
consoleAppender.setLayout(new PatternLayout(PATTERN));
consoleAppender.setThreshold(LOG_LEVEL);
consoleAppender.activateOptions();
AsyncAppender asyncConsoleAppender = new AsyncAppender();
asyncConsoleAppender.addAppender(consoleAppender);
asyncConsoleAppender.setBufferSize(1024);
asyncConsoleAppender.activateOptions();
org.apache.log4j.Logger.getRootLogger().addAppender(asyncConsoleAppender);
FileAppender fileAppender = new FileAppender();
fileAppender.setEncoding("UTF-8");
fileAppender.setFile(filename);
fileAppender.setLayout(new PatternLayout(PATTERN));
fileAppender.setThreshold(LOG_LEVEL);
fileAppender.setAppend(false);
fileAppender.activateOptions();
AsyncAppender asyncFileAppender = new AsyncAppender();
asyncFileAppender.addAppender(fileAppender);
asyncFileAppender.setBufferSize(1024);
asyncFileAppender.activateOptions();
org.apache.log4j.Logger.getRootLogger().addAppender(asyncFileAppender);
}
示例10: setup
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception
{
logger.debug("Logger repository before LoggerUtil.changeLoggersLevel() {}", LogManager.getLoggerRepository());
LoggerUtil.changeLoggersLevel(Maps.<String, String>newHashMap());
logger.debug("Logger repository after LoggerUtil.changeLoggersLevel() {}", LogManager.getLoggerRepository());
log4jLogger.setLevel(Level.TRACE);
Category category = log4jLogger;
while (category != null) {
Enumeration appenders = category.getAllAppenders();
while (appenders.hasMoreElements()) {
Object o = appenders.nextElement();
if (o instanceof AppenderSkeleton) {
AppenderSkeleton appender = (AppenderSkeleton)o;
if (!appenderLevelMap.containsKey(appender)) {
appenderLevelMap.put(appender, appender.getThreshold());
appender.setThreshold(Level.INFO);
}
}
}
if (category.getAdditivity()) {
category = category.getParent();
} else {
category = null;
}
}
}
示例11: teardown
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
@AfterClass
public static void teardown()
{
for (Map.Entry<AppenderSkeleton, Priority> e : appenderLevelMap.entrySet()) {
e.getKey().setThreshold(e.getValue());
}
}
示例12: addErrorAppender
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
/**
* Add a usage appender for the root logger. This appender will write ERROR and FATAL log messages
* to the usage database.
*/
public static void addErrorAppender() {
usageAppender = new AppenderSkeleton() {
boolean logAll = Boolean.getBoolean("logAll");
PatternLayout patternLayout = new PatternLayout("[%t] %c - %m");
@Override
protected void append(LoggingEvent event) {
if (logAll || event.getLevel().equals(Level.ERROR) ||
event.getLevel().equals(Level.FATAL)) {
ThrowableInformation info = event.getThrowableInformation();
StringBuffer buf = new StringBuffer();
if (info == null) buf.append("No stack trace");
else {
for (String line : info.getThrowableStrRep())
buf.append(line).append('\n');
}
EnsembleUsageLogger.logUsage(
event.getLevel().toString(),
patternLayout.format(event) +" -- "+ buf.toString());
}
}
@Override
public void close() { /* do nothing */ }
@Override
public boolean requiresLayout() { return false; }
};
Logger.getRootLogger().addAppender(usageAppender);
}
示例13: setUp
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
@Before
public void setUp()
throws SQLException, IOException, InterruptedException
{
Appender a = Logger.getRootLogger().getAppender("STDERR");
if (a instanceof AppenderSkeleton) {
((AppenderSkeleton) a).setThreshold(Level.DEBUG);
}
dbManager.cleanup();
servers.cleanupA();
servers.startA();
servers.waitUntilAIsActive();
servers.createDatabaseA();
tr.startup();
}
示例14: testBroadcastMessage
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
public void testBroadcastMessage() throws IOException {
success = false;
Logger jcl = Logger.getLogger(JarCacheUpdateHandler.class);
String uri = "jar://mytest/testjar1.jar";
sb = new StringBuilder();
final BasePipelineIntTest monitor = this;
Appender app = new AppenderSkeleton() {
@Override
public void close() {
}
@Override
public boolean requiresLayout() {
return false;
}
@Override
protected void append(LoggingEvent event) {
sb.append(event.getMessage());
success = true;
synchronized (this) {
this.notify();
}
}
};
jcl.addAppender(app);
RapturePipelineTask task = new RapturePipelineTask();
MimeJarCacheUpdate mime = new MimeJarCacheUpdate();
mime.setJarUri(new RaptureURI(uri, Scheme.JAR));
mime.setDeletion(true);
task.setContentType(MimeJarCacheUpdate.getMimeType());
task.addMimeObject(mime);
synchronized (app) {
Kernel.getPipeline().broadcastMessageToAll(context, task);
try {
app.wait(5000);
} catch (Exception e) {
}
}
assertTrue("log appender was not called after 5s", success);
Assert.assertEquals("Updating jar cache for jar uri [jar://mytest/testjar1.jar]", sb.toString());
}
示例15: testBroadcastMessage
import org.apache.log4j.AppenderSkeleton; //导入依赖的package包/类
public void testBroadcastMessage() throws IOException {
success = false;
Logger jcl = Logger.getLogger(JarCacheUpdateHandler.class);
String uri = "jar://mytest/testjar1.jar";
sb = new StringBuilder();
final BasePipeline2IntTest monitor = this;
Appender app = new AppenderSkeleton() {
@Override
public void close() {
}
@Override
public boolean requiresLayout() {
return false;
}
@Override
protected void append(LoggingEvent event) {
sb.append(event.getMessage());
success = true;
synchronized (this) {
this.notify();
}
}
};
jcl.addAppender(app);
MimeJarCacheUpdate mime = new MimeJarCacheUpdate();
mime.setJarUri(new RaptureURI(uri, Scheme.JAR));
mime.setDeletion(true);
synchronized (app) {
TaskSubmitter.submitBroadcastToAll(context, mime, MimeJarCacheUpdate.getMimeType(), null);
// Kernel.getPipeline2().getTrusted().broadcastMessageToAll(context, task);
try {
app.wait(20000);
} catch (Exception e) {
}
}
assertTrue("log appender was not called after 20s", success);
Assert.assertTrue(sb.toString().startsWith("Updating jar cache for jar uri [jar://mytest/testjar1.jar]"));
}