本文整理了Java中ch.qos.logback.core.Appender.start()
方法的一些代码示例,展示了Appender.start()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Appender.start()
方法的具体详情如下:
包路径:ch.qos.logback.core.Appender
类名称:Appender
方法名:start
暂无
代码示例来源:origin: ctripcorp/apollo
private void tryConfigCLogging() throws Exception {
String appId = Foundation.app().getAppId();
if (Strings.isNullOrEmpty(appId)) {
logger.warn("App id is null or empty!");
return;
}
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
Class clazz = Class.forName(cLoggingAppenderClass);
Appender cLoggingAppender = (Appender) clazz.newInstance();
ReflectionUtils.findMethod(clazz, "setAppId", String.class).invoke(cLoggingAppender, appId);
ReflectionUtils.findMethod(clazz, "setServerIp", String.class)
.invoke(cLoggingAppender, cloggingUrl());
ReflectionUtils.findMethod(clazz, "setServerPort", int.class)
.invoke(cLoggingAppender, Integer.parseInt(cloggingPort()));
cLoggingAppender.setName("CentralLogging");
cLoggingAppender.setContext(loggerContext);
cLoggingAppender.start();
ch.qos.logback.classic.Logger logger =
(ch.qos.logback.classic.Logger) LoggerFactory.getLogger("root");
logger.addAppender(cLoggingAppender);
}
代码示例来源:origin: caskdata/cdap
@Override
public void start() {
delegate.start();
}
代码示例来源:origin: co.cask.cdap/cdap-watchdog
@Override
public void start() {
delegate.start();
}
代码示例来源:origin: io.projectreactor/reactor-logback
private void startDelegateAppender() {
Appender<ILoggingEvent> delegateAppender = delegate.get();
if (null != delegateAppender && !delegateAppender.isStarted()) {
delegateAppender.start();
}
}
代码示例来源:origin: io.projectreactor.addons/reactor-logback
private void startDelegateAppender() {
Appender<ILoggingEvent> delegateAppender = delegate.get();
if (null != delegateAppender && !delegateAppender.isStarted()) {
delegateAppender.start();
}
}
代码示例来源:origin: apache/jackrabbit-oak
public void starting() {
customLogger.start();
if (enableLevel != null) {
logger.setLevel(enableLevel);
}
logger.addAppender(customLogger);
}
代码示例来源:origin: korpling/ANNIS
private void addAppender()
{
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(lc);
Appender<ILoggingEvent> appender = new AppenderBase<ILoggingEvent>()
{
@Override
protected void append(ILoggingEvent event)
{
if (event.getLevel().isGreaterOrEqual(Level.INFO))
{
lblStatus.setText(event.getFormattedMessage());
}
}
};
ch.qos.logback.classic.Logger rootLogger = lc.getLogger(
Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(appender);
appender.start();
}
代码示例来源:origin: korpling/ANNIS
private void addAppender()
{
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(lc);
Appender<ILoggingEvent> appender = new AppenderBase<ILoggingEvent>()
{
@Override
protected void append(ILoggingEvent event)
{
if (currentJob != null
&& event.getLevel().isGreaterOrEqual(Level.INFO)
&& event.getLoggerName().equals("annis.administration.AdministrationDao"))
{
currentJob.getMessages().add(event.toString());
}
}
};
ch.qos.logback.classic.Logger rootLogger = lc.getLogger(
Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(appender);
appender.start();
}
代码示例来源:origin: Audiveris/audiveris
/**
* Add a specific appender meant for GUI log pane.
* To be called only when running with a GUI.
*/
public static void addGuiAppender ()
{
// GUI (filtered in LogGuiAppender)
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(
Logger.ROOT_LOGGER_NAME);
Appender guiAppender = new LogGuiAppender();
guiAppender.setName("GUI");
guiAppender.setContext(loggerContext);
guiAppender.start();
root.addAppender(guiAppender);
}
代码示例来源:origin: org.openksavi.sponge/sponge-logging
/**
* Starts or stops logging to the console.
*
* @param start starts or stops logging to the console.
*/
@SuppressWarnings("rawtypes")
public static void logToConsole(boolean start) {
Logger rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
if (rootLogger != null && rootLogger instanceof ch.qos.logback.classic.Logger) {
Appender appender = ((ch.qos.logback.classic.Logger) rootLogger).getAppender(CONSOLE_APPENDER_NAME);
if (appender != null) {
if (start) {
appender.start();
} else {
appender.stop();
}
return;
}
}
logger.warn("Unable to reconfigure Logback console logger (appender name '" + CONSOLE_APPENDER_NAME + "').");
}
代码示例来源:origin: stackoverflow.com
public DefaultConfiguration() {
setName(DEFAULT_NAME);
final Layout layout = PatternLayout.createLayout("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n",
null, null, null);
final Appender appender = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT", "Console", "false",
"true");
appender.start();
addAppender(appender);
final LoggerConfig root = getRootLogger();
root.addAppender(appender, null, null);
final String levelName = PropertiesUtil.getProperties().getStringProperty(DEFAULT_LEVEL);
final Level level = levelName != null && Level.valueOf(levelName) != null ?
Level.valueOf(levelName) : Level.ERROR;
root.setLevel(level);
}
代码示例来源:origin: stackoverflow.com
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
Layout<? extends Serializable> layout = PatternLayout.createLayout(PatternLayout.SIMPLE_CONVERSION_PATTERN, config, null,
null,true, true,null,null);
Appender appender = FileAppender.createAppender("/tmp/log4jtest.txt", "false", "false", "File", "true",
"false", "false", "4000", layout, null, "false", null, config);
appender.start();
config.addAppender(appender);
AppenderRef ref = AppenderRef.createAppenderRef("File", null, null);
AppenderRef[] refs = new AppenderRef[] {ref};
LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.INFO, "org.apache.logging.log4j",
"true", refs, null, config, null );
loggerConfig.addAppender(appender, null, null);
config.addLogger("simpleTestLogger", loggerConfig);
ctx.updateLoggers();
Logger l = ctx.getLogger("simpleTestLogger");
l.info("message of info level shoud be output properly");
l.error("error message");
代码示例来源:origin: protegeproject/protege
public void bind() {
applyPreferences();
Logger rootLogger = getRootLogger();
appender.setContext(rootLogger.getLoggerContext());
appender.start();
rootLogger.addAppender(appender);
}
代码示例来源:origin: net.logstash.logback/logstash-logback-encoder
private void startDelegateAppenders() {
for (Iterator<Appender<Event>> appenderIter = appenders.iteratorForAppenders(); appenderIter.hasNext();) {
Appender<Event> appender = appenderIter.next();
if (appender.getContext() == null) {
appender.setContext(getContext());
}
if (!appender.isStarted()) {
appender.start();
}
}
}
代码示例来源:origin: stackoverflow.com
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
Layout layout = PatternLayout.createLayout(PatternLayout.SIMPLE_CONVERSION_PATTERN, config, null, null,null, null);
Appender appender = FileAppender.createAppender("target/test.log", "false", "false", "File", "true", "false", "false", "4000", layout, null, "false", null, config);
appender.start();
config.addAppender(appender);
AppenderRef ref = AppenderRef.createAppenderRef("File", null, null);
AppenderRef[] refs = new AppenderRef[] {ref};
LoggerConfig loggerConfig = LoggerConfig.createLogger("false", "info", "org.apache.logging.log4j", "true", refs, null, config, null );
loggerConfig.addAppender(appender, null, null);
config.addLogger("org.apache.logging.log4j", loggerConfig);
ctx.updateLoggers();
代码示例来源:origin: com.intoverflow.booster/booster-config
@Bean
@ConditionalOnBean(DataSource.class)
public DataSourceConnectionSource connectionSource(DataSource dataSource) {
DataSourceConnectionSource connectionSource = new DataSourceConnectionSource();
connectionSource.setDataSource(dataSource);
connectionSource.start();
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
List<Logger> loggerList = loggerContext.getLoggerList();
for (Logger log : loggerList) {
Iterator<Appender<ILoggingEvent>> iter = log.iteratorForAppenders();
while (iter.hasNext()) {
Appender<ILoggingEvent> appender = iter.next();
if (appender instanceof DBAppender) {
((DBAppender) appender).setConnectionSource(connectionSource);
appender.start();
}
}
}
return connectionSource;
}
}
代码示例来源:origin: stackoverflow.com
public static void initLogFile(String path, Level level){
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
Layout layout = PatternLayout.createLayout(Constants.LOG_PATTERN, null, config, null, null, false, false, null, null);
Appender appender = FileAppender.createAppender(path, "true", "true", "File", "true",
"false", "false", null, layout, null, "false", null, config);
appender.start();
config.addAppender(appender);
AppenderRef ref = AppenderRef.createAppenderRef("File", null, null);
AppenderRef[] refs = new AppenderRef[] {ref};
LoggerConfig loggerConfig = config.getLoggerConfig("com.jorge.myapp.business");
loggerConfig.addAppender(appender, null, null);
ctx.updateLoggers();
}
代码示例来源:origin: com.paypal.butterfly/butterfly-cli
@Override
public void setVerboseMode(boolean verboseMode) {
this.verboseMode = verboseMode;
if (verboseMode) {
PatternLayoutEncoder patternLayoutEncoder = new PatternLayoutEncoder();
patternLayoutEncoder.setPattern("[%d{HH:mm:ss.SSS}] [%highlight(%level)] %msg%n");
patternLayoutEncoder.setContext(loggerContext);
patternLayoutEncoder.start();
Appender<ILoggingEvent> consoleAppender = new ConsoleAppender();
((OutputStreamAppender) consoleAppender).setEncoder(patternLayoutEncoder);
consoleAppender.setContext(loggerContext);
consoleAppender.start();
loggerContext.getLogger("com.paypal.butterfly.cli").detachAppender("CONSOLE");
loggerContext.getLogger("ROOT").addAppender(consoleAppender);
// } else {
// TODO
}
}
代码示例来源:origin: qos-ch/logback-extensions
private Appender<ILoggingEvent> getDelegate() {
ApplicationContext context = ApplicationContextHolder.getApplicationContext();
try {
@SuppressWarnings("unchecked")
Appender<ILoggingEvent> appender = context.getBean(beanName, Appender.class);
appender.setContext(getContext());
if (!appender.isStarted()) {
appender.start();
}
return appender;
} catch (NoSuchBeanDefinitionException e) {
stop();
addError("The ApplicationContext does not contain an Appender named [" + beanName +
"]. This delegating appender will now stop processing events.", e);
}
return null;
}
代码示例来源:origin: tony19/logback-android
@Test
public void testConfiguredAppender() {
Appender<E> appender = getConfiguredAppender();
appender.start();
assertTrue(appender.isStarted());
appender.stop();
assertFalse(appender.isStarted());
}
内容来源于网络,如有侵权,请联系作者删除!