• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LogcatAppender类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ch.qos.logback.classic.android.LogcatAppender的典型用法代码示例。如果您正苦于以下问题:Java LogcatAppender类的具体用法?Java LogcatAppender怎么用?Java LogcatAppender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LogcatAppender类属于ch.qos.logback.classic.android包,在下文中一共展示了LogcatAppender类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: configureLogbackDirectly

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
private static void configureLogbackDirectly() {
    // reset the default context (which may already have been initialized)
    // since we want to reconfigure it
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    lc.reset();

    // setup LogcatAppender
    PatternLayoutEncoder encoder2 = new PatternLayoutEncoder();
    encoder2.setContext(lc);
    encoder2.setPattern("[%thread] %msg%n");
    encoder2.start();

    LogcatAppender logcatAppender = new LogcatAppender();
    logcatAppender.setContext(lc);
    logcatAppender.setEncoder(encoder2);
    logcatAppender.start();

    // backup the newly created appenders to the root logger;
    // qualify Logger to disambiguate from org.slf4j.Logger
    ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.addAppender(logcatAppender);

    root.setLevel(Level.ALL);
}
 
开发者ID:kejunxia,项目名称:AndroidMvc,代码行数:25,代码来源:BaseTestCase.java


示例2: init

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
/**
 * Called to initialize logging. Should be called in {@link android.app.Application#onCreate()}
 *
 * @param context
 * @param writeToLogcat If {@code true} log messages will be written to logcat as well as
 *                      to disk. If {@code false} log messages will only be written to disk.
 *                      Apps should only ever write to logcat in development.
 * @param pattern The log pattern to use. The default is {@link #DEFAULT_PATTERN}
 */
public static void init(Context context, boolean writeToLogcat, String pattern) {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    loggerContext.reset();

    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(loggerContext);
    encoder.setPattern(pattern);
    encoder.start();

    FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>();
    fileAppender.setContext(loggerContext);
    fileAppender.setFile(getFilePath(context));
    fileAppender.setAppend(true);
    fileAppender.setEncoder(encoder);
    fileAppender.start();

    ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger)
            LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.addAppender(fileAppender);

    if (writeToLogcat) {
        LogcatAppender logcatAppender = new LogcatAppender();
        logcatAppender.setContext(loggerContext);
        logcatAppender.setEncoder(encoder);
        logcatAppender.start();

        root.addAppender(logcatAppender);
    }
}
 
开发者ID:lkorth,项目名称:mailable-log,代码行数:39,代码来源:MailableLog.java


示例3: initLog

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
private void initLog(){
    final File logDir = getLogDir();
    final File logFile = new File(logDir, "chaincloud-v.log");
    final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    final PatternLayoutEncoder filePattern = new PatternLayoutEncoder();
    filePattern.setContext(context);
    filePattern.setPattern("%d{HH:mm:ss.SSS} [%thread] %logger{0} - %msg%n");
    filePattern.start();

    final RollingFileAppender<ILoggingEvent> fileAppender = new
            RollingFileAppender<ILoggingEvent>();
    fileAppender.setContext(context);
    fileAppender.setFile(logFile.getAbsolutePath());

    final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new
            TimeBasedRollingPolicy<ILoggingEvent>();
    rollingPolicy.setContext(context);
    rollingPolicy.setParent(fileAppender);
    rollingPolicy.setFileNamePattern(logDir.getAbsolutePath() + "/chaincloud-v.%d.log.gz");
    rollingPolicy.setMaxHistory(7);
    rollingPolicy.start();

    fileAppender.setEncoder(filePattern);
    fileAppender.setRollingPolicy(rollingPolicy);
    fileAppender.start();

    final PatternLayoutEncoder logcatTagPattern = new PatternLayoutEncoder();
    logcatTagPattern.setContext(context);
    logcatTagPattern.setPattern("%logger{0}");
    logcatTagPattern.start();

    final PatternLayoutEncoder logcatPattern = new PatternLayoutEncoder();
    logcatPattern.setContext(context);
    logcatPattern.setPattern("[%thread] %msg%n");
    logcatPattern.start();

    final LogcatAppender logcatAppender = new LogcatAppender();
    logcatAppender.setContext(context);
    logcatAppender.setTagEncoder(logcatTagPattern);
    logcatAppender.setEncoder(logcatPattern);
    logcatAppender.start();

    final ch.qos.logback.classic.Logger log = context.getLogger(Logger.ROOT_LOGGER_NAME);
    log.addAppender(fileAppender);
    log.addAppender(logcatAppender);
    log.setLevel(Level.INFO);
}
 
开发者ID:chaincloud-dot-com,项目名称:chaincloud-v,代码行数:48,代码来源:ChainCloudVApplication.java


示例4: initLogging

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
private void initLogging()
{
    final File logDir = getDir("log", Constants.TEST ? Context.MODE_WORLD_READABLE : MODE_PRIVATE);
    final File logFile = new File(logDir, "wallet.log");

    final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

    final PatternLayoutEncoder filePattern = new PatternLayoutEncoder();
    filePattern.setContext(context);
    filePattern.setPattern("%d{HH:mm:ss.SSS} [%thread] %logger{0} - %msg%n");
    filePattern.start();

    final RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
    fileAppender.setContext(context);
    fileAppender.setFile(logFile.getAbsolutePath());

    final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
    rollingPolicy.setContext(context);
    rollingPolicy.setParent(fileAppender);
    rollingPolicy.setFileNamePattern(logDir.getAbsolutePath() + "/wallet.%d.log.gz");
    rollingPolicy.setMaxHistory(7);
    rollingPolicy.start();

    fileAppender.setEncoder(filePattern);
    fileAppender.setRollingPolicy(rollingPolicy);
    fileAppender.start();

    final PatternLayoutEncoder logcatTagPattern = new PatternLayoutEncoder();
    logcatTagPattern.setContext(context);
    logcatTagPattern.setPattern("%logger{0}");
    logcatTagPattern.start();

    final PatternLayoutEncoder logcatPattern = new PatternLayoutEncoder();
    logcatPattern.setContext(context);
    logcatPattern.setPattern("[%thread] %msg%n");
    logcatPattern.start();

    final LogcatAppender logcatAppender = new LogcatAppender();
    logcatAppender.setContext(context);
    logcatAppender.setTagEncoder(logcatTagPattern);
    logcatAppender.setEncoder(logcatPattern);
    logcatAppender.start();

    final ch.qos.logback.classic.Logger log = context.getLogger(Logger.ROOT_LOGGER_NAME);
    log.addAppender(fileAppender);
    log.addAppender(logcatAppender);
    log.setLevel(Level.INFO);
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:49,代码来源:WalletApplication.java


示例5: configureLogger

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
private void configureLogger() {
    File targetFile = new File(LOGFILE_PATH);

    // reset the default context (which may already have been initialized)
    // since we want to reconfigure it
    LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
    lc.reset();

    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(lc);
    encoder.setPattern("%d{yyyy-MM-dd HH:mm:ss.SSS} : %-5level : %msg%n");
    encoder.start();

    String filePattern = targetFile.getParent() + "/" + targetFile.getName() + ".%i.zip";
    FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
    rollingPolicy.setFileNamePattern(filePattern);
    rollingPolicy.setMinIndex(1);
    rollingPolicy.setMaxIndex(3);
    rollingPolicy.setContext(lc);

    SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>();
    triggeringPolicy.setMaxFileSize("5MB");
    triggeringPolicy.setContext(lc);

    RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<ILoggingEvent>();
    rollingFileAppender.setAppend(true);
    rollingFileAppender.setName("FILE");
    rollingFileAppender.setContext(lc);
    rollingFileAppender.setFile(LOGFILE_PATH);
    rollingFileAppender.setRollingPolicy(rollingPolicy);
    rollingFileAppender.setTriggeringPolicy(triggeringPolicy);
    rollingFileAppender.setEncoder(encoder);

    triggeringPolicy.start();
    rollingPolicy.setParent(rollingFileAppender);
    rollingPolicy.start();
    rollingFileAppender.start();

    // Logcat appender
    LogcatAppender logcatAppender = new LogcatAppender();
    logcatAppender.setContext(lc);
    logcatAppender.setName("LOGCAT");
    logcatAppender.setEncoder(encoder);
    logcatAppender.start();

    // add the newly created appenders to the root logger;
    // qualify Logger to disambiguate from org.slf4j.Logger
    ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.ALL);
    root.addAppender(rollingFileAppender);
    root.addAppender(logcatAppender);
}
 
开发者ID:andischerer,项目名称:cordova-plugin-logtofile,代码行数:53,代码来源:LogToFile.java


示例6: initLogging

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
private void initLogging()
{
    final File logDir = getDir("log", TEST ? Context.MODE_WORLD_READABLE : MODE_PRIVATE);
    final File logFile = new File(logDir, "wallet.log");

    final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

    final PatternLayoutEncoder filePattern = new PatternLayoutEncoder();
    filePattern.setContext(context);
    filePattern.setPattern("%d{HH:mm:ss.SSS} [%thread] %logger{0} - %msg%n");
    filePattern.start();

    final RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
    fileAppender.setContext(context);
    fileAppender.setFile(logFile.getAbsolutePath());

    final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
    rollingPolicy.setContext(context);
    rollingPolicy.setParent(fileAppender);
    rollingPolicy.setFileNamePattern(logDir.getAbsolutePath() + "/wallet.%d.log.gz");
    rollingPolicy.setMaxHistory(7);
    rollingPolicy.start();

    fileAppender.setEncoder(filePattern);
    fileAppender.setRollingPolicy(rollingPolicy);
    fileAppender.start();

    final PatternLayoutEncoder logcatTagPattern = new PatternLayoutEncoder();
    logcatTagPattern.setContext(context);
    logcatTagPattern.setPattern("%logger{0}");
    logcatTagPattern.start();

    final PatternLayoutEncoder logcatPattern = new PatternLayoutEncoder();
    logcatPattern.setContext(context);
    logcatPattern.setPattern("[%thread] %msg%n");
    logcatPattern.start();

    final LogcatAppender logcatAppender = new LogcatAppender();
    logcatAppender.setContext(context);
    logcatAppender.setTagEncoder(logcatTagPattern);
    logcatAppender.setEncoder(logcatPattern);
    logcatAppender.start();

    final ch.qos.logback.classic.Logger log = context.getLogger(Logger.ROOT_LOGGER_NAME);
    log.addAppender(fileAppender);
    log.addAppender(logcatAppender);
    log.setLevel(Level.INFO);
}
 
开发者ID:RCasatta,项目名称:EternityWallAndroid,代码行数:49,代码来源:EWApplication.java


示例7: configureLogbackDirectly

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
private void configureLogbackDirectly() {
    // reset the default context (which may already have been initialized)
    // since we want to reconfigure it
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    lc.reset();

    // setup FileAppender
    PatternLayoutEncoder encoder1 = new PatternLayoutEncoder();
    encoder1.setContext(lc);
    encoder1.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
    encoder1.start();

    FileAppender<ILoggingEvent> fileAppender = new FileAppender<>();
    fileAppender.setContext(lc);
    fileAppender.setFile(this.getFileStreamPath("app.log").getAbsolutePath());
    fileAppender.setEncoder(encoder1);
    fileAppender.start();

    // setup LogcatAppender
    PatternLayoutEncoder encoder2 = new PatternLayoutEncoder();
    encoder2.setContext(lc);
    encoder2.setPattern("[%thread] %msg%n");
    encoder2.start();

    LogcatAppender logcatAppender = new LogcatAppender();
    logcatAppender.setContext(lc);
    logcatAppender.setEncoder(encoder2);
    logcatAppender.start();

    // backup the newly created appenders to the root logger;
    // qualify Logger to disambiguate from org.slf4j.Logger
    ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.addAppender(fileAppender);
    root.addAppender(logcatAppender);

    if (BuildConfig.DEBUG) {
        root.setLevel(Level.ALL);
    } else {
        root.setLevel(Level.INFO);
    }
}
 
开发者ID:kejunxia,项目名称:AndroidMvc,代码行数:42,代码来源:MvcApp.java


示例8: initLogging

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
private void initLogging() {
    final File logDir = getLogDir();
    final File logFile = new File(logDir, "bitherj.log");
    final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    final PatternLayoutEncoder filePattern = new PatternLayoutEncoder();
    filePattern.setContext(context);
    filePattern.setPattern("%d{HH:mm:ss.SSS} [%thread] %logger{0} - %msg%n");
    filePattern.start();

    final RollingFileAppender<ILoggingEvent> fileAppender = new
            RollingFileAppender<ILoggingEvent>();
    fileAppender.setContext(context);
    fileAppender.setFile(logFile.getAbsolutePath());

    final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new
            TimeBasedRollingPolicy<ILoggingEvent>();
    rollingPolicy.setContext(context);
    rollingPolicy.setParent(fileAppender);
    rollingPolicy.setFileNamePattern(logDir.getAbsolutePath() + "/bitherj.%d.log.gz");
    rollingPolicy.setMaxHistory(7);
    rollingPolicy.start();

    fileAppender.setEncoder(filePattern);
    fileAppender.setRollingPolicy(rollingPolicy);
    fileAppender.start();

    final PatternLayoutEncoder logcatTagPattern = new PatternLayoutEncoder();
    logcatTagPattern.setContext(context);
    logcatTagPattern.setPattern("%logger{0}");
    logcatTagPattern.start();

    final PatternLayoutEncoder logcatPattern = new PatternLayoutEncoder();
    logcatPattern.setContext(context);
    logcatPattern.setPattern("[%thread] %msg%n");
    logcatPattern.start();

    final LogcatAppender logcatAppender = new LogcatAppender();
    logcatAppender.setContext(context);
    logcatAppender.setTagEncoder(logcatTagPattern);
    logcatAppender.setEncoder(logcatPattern);
    logcatAppender.start();

    final ch.qos.logback.classic.Logger log = context.getLogger(Logger.ROOT_LOGGER_NAME);
    log.addAppender(fileAppender);
    log.addAppender(logcatAppender);
    log.setLevel(Level.INFO);
}
 
开发者ID:bither,项目名称:bither-android,代码行数:48,代码来源:BitherApplication.java


示例9: initLogging

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
private void initLogging()
{
	final File logDir = getDir("log", MODE_PRIVATE); // Context.MODE_WORLD_READABLE
	final File logFile = new File(logDir, "btcreceive.log");

	final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

	final PatternLayoutEncoder filePattern = new PatternLayoutEncoder();
	filePattern.setContext(context);
	filePattern.setPattern("%d{HH:mm:ss.SSS} [%thread] %logger{0} - %msg%n");
	filePattern.start();

	final RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
	fileAppender.setContext(context);
	fileAppender.setFile(logFile.getAbsolutePath());

	final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
	rollingPolicy.setContext(context);
	rollingPolicy.setParent(fileAppender);
	rollingPolicy.setFileNamePattern(logDir.getAbsolutePath() + "/btcreceive.%d.log.gz");
	rollingPolicy.setMaxHistory(7);
	rollingPolicy.start();

	fileAppender.setEncoder(filePattern);
	fileAppender.setRollingPolicy(rollingPolicy);
	fileAppender.start();

	final PatternLayoutEncoder logcatTagPattern = new PatternLayoutEncoder();
	logcatTagPattern.setContext(context);
	logcatTagPattern.setPattern("%logger{0}");
	logcatTagPattern.start();

	final PatternLayoutEncoder logcatPattern = new PatternLayoutEncoder();
	logcatPattern.setContext(context);
	logcatPattern.setPattern("[%thread] %msg%n");
	logcatPattern.start();

	final LogcatAppender logcatAppender = new LogcatAppender();
	logcatAppender.setContext(context);
	logcatAppender.setTagEncoder(logcatTagPattern);
	logcatAppender.setEncoder(logcatPattern);
	logcatAppender.start();

	final ch.qos.logback.classic.Logger log = context.getLogger(Logger.ROOT_LOGGER_NAME);
	log.addAppender(fileAppender);
	log.addAppender(logcatAppender);
	log.setLevel(Level.INFO);
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:49,代码来源:WalletApplication.java


示例10: initLogging

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
private void initLogging()
{
	final File logDir = getDir("log", Constants.TEST ? Context.MODE_WORLD_READABLE : MODE_PRIVATE);
	final File logFile = new File(logDir, "wallet.log");

	final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

	final PatternLayoutEncoder filePattern = new PatternLayoutEncoder();
	filePattern.setContext(context);
	filePattern.setPattern("%d{HH:mm:ss.SSS} [%thread] %logger{0} - %msg%n");
	filePattern.start();

	final RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
	fileAppender.setContext(context);
	fileAppender.setFile(logFile.getAbsolutePath());

	final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
	rollingPolicy.setContext(context);
	rollingPolicy.setParent(fileAppender);
	rollingPolicy.setFileNamePattern(logDir.getAbsolutePath() + "/wallet.%d.log.gz");
	rollingPolicy.setMaxHistory(7);
	rollingPolicy.start();

	fileAppender.setEncoder(filePattern);
	fileAppender.setRollingPolicy(rollingPolicy);
	fileAppender.start();

	final PatternLayoutEncoder logcatTagPattern = new PatternLayoutEncoder();
	logcatTagPattern.setContext(context);
	logcatTagPattern.setPattern("%logger{0}");
	logcatTagPattern.start();

	final PatternLayoutEncoder logcatPattern = new PatternLayoutEncoder();
	logcatPattern.setContext(context);
	logcatPattern.setPattern("[%thread] %msg%n");
	logcatPattern.start();

	final LogcatAppender logcatAppender = new LogcatAppender();
	logcatAppender.setContext(context);
	logcatAppender.setTagEncoder(logcatTagPattern);
	logcatAppender.setEncoder(logcatPattern);
	logcatAppender.start();

	final ch.qos.logback.classic.Logger log = context.getLogger(Logger.ROOT_LOGGER_NAME);
	log.addAppender(fileAppender);
	log.addAppender(logcatAppender);
	log.setLevel(Level.INFO);
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:49,代码来源:WalletApplication.java


示例11: initLogging

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
/**
 * Initialize and configure the logback logging.
 * Java configuration is used to rely on {@link Context#getExternalFilesDir(String)} to provide a storage directory.
 * This must be called on every "entry-point" to this app, e.g. Widget Configuration screen or MainActivity.
 *
 * @param context application context
 */
public static void initLogging(Context context) {
    final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean isDebugLogging = sharedPrefs.getBoolean(SettingsActivity.KEY_PREF_DEBUG_LOGGING, false);
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    lc.reset();
    // qualify Logger to disambiguate from org.slf4j.Logger
    ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.TRACE);

    PatternLayoutEncoder encoder1 = new PatternLayoutEncoder();
    encoder1.setContext(lc);
    encoder1.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
    encoder1.start();

    // setup LogcatAppender
    PatternLayoutEncoder encoder2 = new PatternLayoutEncoder();
    encoder2.setContext(lc);
    encoder2.setPattern("[%thread] %msg%n");
    encoder2.start();

    LogcatAppender logcatAppender = new LogcatAppender();
    logcatAppender.setContext(lc);
    logcatAppender.setEncoder(encoder2);
    logcatAppender.start();

    // Log-Level for RaspiCheck
    ch.qos.logback.classic.Logger rpicheckLogger = (ch.qos.logback.classic.Logger) LoggerFactory
            .getLogger("de.eidottermihi.rpicheck");
    rpicheckLogger.setLevel(isDebugLogging ? Level.DEBUG : Level.INFO);
    ch.qos.logback.classic.Logger sshjLogger = (ch.qos.logback.classic.Logger) LoggerFactory
            .getLogger("net.schmizz");
    sshjLogger.setLevel(Level.WARN);

    // setup FileAppender
    String logPath = getLogfilePath(context);
    if (logPath != null) {
        FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>();
        fileAppender.setContext(lc);
        fileAppender.setFile(logPath);
        fileAppender.setEncoder(encoder1);
        fileAppender.start();
        rpicheckLogger.addAppender(fileAppender);
        sshjLogger.addAppender(fileAppender);
    }
    root.addAppender(logcatAppender);
    LOGGER.debug("Logging was configured, debug logging enabled: {}", isDebugLogging);
}
 
开发者ID:eidottermihi,项目名称:rpicheck,代码行数:55,代码来源:LoggingHelper.java


示例12: initLogs

import ch.qos.logback.classic.android.LogcatAppender; //导入依赖的package包/类
private static void initLogs() {
    Logger logbackLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    LoggerContext lc = logbackLogger.getLoggerContext();

    Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.detachAndStopAllAppenders();

    TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
    rollingPolicy.setMaxHistory(3);
    SizeAndTimeBasedFNATP<ILoggingEvent> sizeAndTimeBasedFNATP = new SizeAndTimeBasedFNATP<ILoggingEvent>();
    sizeAndTimeBasedFNATP.setMaxFileSize("2MB");
    rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(sizeAndTimeBasedFNATP);
    rollingPolicy.setFileNamePattern(context.getFilesDir().getPath() + "/logs/old/flickruploader.%d{yyyy-MM-dd}.%i.log");
    rollingPolicy.setContext(lc);

    RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
    fileAppender.setContext(lc);
    fileAppender.setFile(getLogFilePath());
    fileAppender.setRollingPolicy(rollingPolicy);
    fileAppender.setTriggeringPolicy(rollingPolicy);
    rollingPolicy.setParent(fileAppender);

    PatternLayoutEncoder pl = new PatternLayoutEncoder();
    pl.setContext(lc);
    pl.setCharset(Charset.defaultCharset());
    pl.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %class{0}.%method:%L > %msg%n");
    pl.setImmediateFlush(false);
    pl.start();

    fileAppender.setEncoder(pl);
    fileAppender.setName("file");

    rollingPolicy.start();
    fileAppender.start();

    if (Config.isDebug()) {
        final PatternLayoutEncoder logcatTagPattern = new PatternLayoutEncoder();
        logcatTagPattern.setContext(lc);
        logcatTagPattern.setPattern("%class{0}");
        logcatTagPattern.start();

        final PatternLayoutEncoder logcatPattern = new PatternLayoutEncoder();
        logcatPattern.setContext(lc);
        logcatPattern.setPattern("[%thread] %method:%L > %msg%n");
        logcatPattern.start();

        final LogcatAppender logcatAppender = new LogcatAppender();
        logcatAppender.setContext(lc);
        logcatAppender.setTagEncoder(logcatTagPattern);
        logcatAppender.setEncoder(logcatPattern);
        logcatAppender.start();

        rootLogger.addAppender(logcatAppender);
    }

    rootLogger.addAppender(fileAppender);

}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:59,代码来源:FlickrUploader.java



注:本文中的ch.qos.logback.classic.android.LogcatAppender类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IDeviceService类代码示例发布时间:2022-05-21
下一篇:
Java ModelBuildingException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap