当前位置: 首页>>代码示例>>Java>>正文


Java PatternLayoutEncoder.setCharset方法代码示例

本文整理汇总了Java中ch.qos.logback.classic.encoder.PatternLayoutEncoder.setCharset方法的典型用法代码示例。如果您正苦于以下问题:Java PatternLayoutEncoder.setCharset方法的具体用法?Java PatternLayoutEncoder.setCharset怎么用?Java PatternLayoutEncoder.setCharset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.qos.logback.classic.encoder.PatternLayoutEncoder的用法示例。


在下文中一共展示了PatternLayoutEncoder.setCharset方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildAppender

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
protected Appender buildAppender(String name, String fileName, String pattern) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setContext(loggerContext);
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setContext(loggerContext);
    rolling.setParent(appender);
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd}");
    rolling.start();
    appender.setRollingPolicy(rolling);

    PatternLayoutEncoder layout = new PatternLayoutEncoder();
    layout.setContext(loggerContext);
    layout.setPattern(pattern);
    layout.setCharset(Charset.forName(getEncoding()));
    layout.start();
    appender.setEncoder(layout);
    // 启动
    appender.start();
    return appender;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:25,代码来源:DynamicLogbackLogger.java

示例2: buildDailyMaxRollingAppender

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
protected Appender buildDailyMaxRollingAppender(String name, String fileName, String pattern, int maxBackupIndex) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setContext(loggerContext);
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setContext(loggerContext);
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd-HH}");
    rolling.setMaxHistory(maxBackupIndex);
    rolling.setParent(appender);
    rolling.start();
    appender.setRollingPolicy(rolling);

    PatternLayoutEncoder layout = new PatternLayoutEncoder();
    layout.setContext(loggerContext);
    layout.setPattern(pattern);
    layout.setCharset(Charset.forName(getEncoding()));
    layout.start();
    appender.setEncoder(layout);
    // 启动
    appender.start();
    return appender;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:26,代码来源:DynamicLogbackLogger.java

示例3: buildAppender

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
private Appender buildAppender(String name, String fileName, String pattern) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setParent(appender);
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd}");
    appender.setRollingPolicy(rolling);

    PatternLayoutEncoder layout = new PatternLayoutEncoder();
    layout.setPattern(pattern);
    layout.setCharset(Charset.forName(getEncoding()));
    appender.setEncoder(layout);
    // 启动
    appender.start();
    return appender;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:20,代码来源:DynamicLogbackLogger.java

示例4: buildDailyMaxRollingAppender

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
private Appender buildDailyMaxRollingAppender(String name, String fileName, String pattern, int maxBackupIndex) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd-HH}");
    rolling.setMaxHistory(maxBackupIndex);
    rolling.setParent(appender);
    appender.setRollingPolicy(rolling);

    PatternLayoutEncoder layout = new PatternLayoutEncoder();
    layout.setPattern(pattern);
    layout.setCharset(Charset.forName(getEncoding()));
    appender.setEncoder(layout);
    // 启动
    appender.start();
    return appender;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:21,代码来源:DynamicLogbackLogger.java

示例5: configure

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
public static void configure(LoggerContext loggerContext) {
    loggerContext.reset();

    StatusManager sm = loggerContext.getStatusManager();
    if (sm != null) {
        sm.add(new InfoStatus("Setting up default Pipes configuration.", loggerContext));
    }

    ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
    ca.setContext(loggerContext);
    ca.setWithJansi(true);
    ca.setName("console");

    PatternLayoutEncoder pl = new PatternLayoutEncoder();
    pl.setCharset(Charset.forName("UTF-8"));
    pl.setContext(loggerContext);
    //pl.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
    pl.setPattern("%msg%n");
    pl.start();

    ca.setEncoder(pl);
    ca.start();
    ch.qos.logback.classic.Logger rootLogger = loggerContext.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
    rootLogger.setLevel(Level.INFO);
    rootLogger.addAppender(ca);
}
 
开发者ID:wmluke,项目名称:pipes,代码行数:27,代码来源:LogbackConfig.java

示例6: getStdErrAppender

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
/**
 * Create a stderr appender.
 *
 * @param context The logger context to use.
 * @return An appender writing to stderr.
 */
private static Appender<ILoggingEvent> getStdErrAppender(final LoggerContext context) {

  // Setup format
  final PatternLayoutEncoder encoder = new PatternLayoutEncoder();
  encoder.setContext(context);
  encoder.setPattern(
      "%date{HH:mm:ss.SSS} %property{ident}[%property{pid}]: %-5level [%thread] %logger{0}: %msg%n");
  encoder.setCharset(Charsets.UTF_8);
  encoder.start();

  // Setup stderr appender
  final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
  appender.setTarget("System.err");
  appender.setName("stderr");
  appender.setEncoder(encoder);
  appender.setContext(context);
  appender.start();

  return appender;
}
 
开发者ID:spotify,项目名称:logging-java,代码行数:27,代码来源:LoggingConfigurator.java

示例7: consoleAppender

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
private Appender<ILoggingEvent> consoleAppender(LogbackConfigurator config) {
	ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
	PatternLayoutEncoder encoder = new PatternLayoutEncoder();
	String logPattern = this.patterns.getProperty("console", CONSOLE_LOG_PATTERN);
	encoder.setPattern(OptionHelper.substVars(logPattern, config.getContext()));
	encoder.setCharset(UTF8);
	config.start(encoder);
	appender.setEncoder(encoder);
	config.appender("CONSOLE", appender);
	return appender;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:DefaultLogbackConfiguration.java

示例8: configure

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
/**
 * Configure logging based on a list of builders provided to it. Injects the
 * configured logging to replace the default UIMA loggers, and also sets up
 * metrics on the logging.
 *
 * @param builders
 *            The builders to use to configure the logging
 */
public void configure(List<BaleenLoggerBuilder> builders) {
	// Install JUL to SLF4J handling (JUL is default for UIMA)
	SLF4JBridgeHandler.removeHandlersForRootLogger();
	SLF4JBridgeHandler.install();

	// Configure Logback
	LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
	Logger rootLogger = context.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);

	// Install the level change propagator to reduce the impact of JUL logging
	context.addListener(new LevelChangePropagator());

	// Remove all the existing appenders
	rootLogger.detachAndStopAllAppenders();

	for (BaleenLoggerBuilder builder : builders) {
		PatternLayoutEncoder ple = new PatternLayoutEncoder();
		ple.setCharset(StandardCharsets.UTF_8);
		ple.setContext(context);
		ple.setPattern(builder.getPattern());
		ple.start();

		Appender<ILoggingEvent> appender = builder.build(context, ple);
		if (!appender.isStarted()) {
			appender.start();
		}

		rootLogger.addAppender(appender);
	}

	LOGGER.debug("Adding instrumented metrics for logging");
	// Add an instrumented appender so we get the information about logging
	// through metrics
	InstrumentedAppender instrumentedAppender = new InstrumentedAppender(MetricsFactory.getInstance().getRegistry());
	instrumentedAppender.setContext(context);
	instrumentedAppender.start();
	rootLogger.addAppender(instrumentedAppender);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:47,代码来源:BaleenLogging.java

示例9: buildPatternLayoutEncoder

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
private PatternLayoutEncoder buildPatternLayoutEncoder(String pattern) {
    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setCharset(StandardCharsets.UTF_8);
    encoder.setPattern(pattern);

    return this.buildLifeCycle(encoder, true);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:8,代码来源:LoggingInitializerRunListener.java

示例10: configureLogback

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
private static void configureLogback(Service.Instance instance) {
  final Config config = instance.getConfig();
  final int level = config.hasPath("logging.verbosity")
      ? config.getInt("logging.verbosity")
      : 0;

  final ch.qos.logback.classic.Logger
      floLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("com.spotify.flo");

  if (level > 1) {
    floLogger.setLevel(Level.TRACE);
  } else if (level > 0) {
    floLogger.setLevel(Level.DEBUG);
  }

  if (level > 0) {
    final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    final ch.qos.logback.classic.Logger
        rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(
        ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
    final ConsoleAppender<ILoggingEvent> stdout =
        (ConsoleAppender<ILoggingEvent>) rootLogger.getAppender("STDOUT");
    final PatternLayoutEncoder layout = new PatternLayoutEncoder();
    layout.setPattern("%gray(%d{HH:mm:ss.SSS} %-28thread) %highlight(| %-5level| %-10logger{0}) "
                      + "%green(|>) %msg%n");
    layout.setCharset(StandardCharsets.UTF_8);
    layout.setContext(lc);
    layout.start();

    stdout.setEncoder(layout);
    stdout.start();
  }
}
 
开发者ID:spotify,项目名称:flo,代码行数:34,代码来源:ConsoleLogging.java

示例11: dynamic

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
private static Logger dynamic(String name, LogLevel level) {
	// ( LoggerContext ) LoggerFactory.getILoggerFactory();
	/*
	 * String thName = Thread.currentThread().getName(); if( thName != null
	 * && !thName.trim().isEmpty() ) name = name + "_" +
	 * thName.trim().replaceAll( " ", "_" );
	 */
	PatternLayoutEncoder encoder = new PatternLayoutEncoder();
	encoder.setPattern("%d{HH:mm:ss.SSS} [%thread][%-5level][%logger{36}] - %msg%n");
	encoder.setContext(context);
	encoder.setCharset(Charset.forName("UTF-8"));

	DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent> timeBasedTriggeringPolicy = new DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent>();
	timeBasedTriggeringPolicy.setContext(context);

	TimeBasedRollingPolicy<ILoggingEvent> timeBasedRollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
	timeBasedRollingPolicy.setContext(context);
	String workspace = System.getenv("WORKSPACE");
	if (workspace == null)
		workspace = "";
	if (!workspace.isEmpty() && !workspace.endsWith("/"))
		workspace += "/";
	timeBasedRollingPolicy.setFileNamePattern(workspace + "logs/" + name + "-%d{yyyy-MM-dd}.log");
	timeBasedRollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(timeBasedTriggeringPolicy);

	timeBasedTriggeringPolicy.setTimeBasedRollingPolicy(timeBasedRollingPolicy);

	RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<ILoggingEvent>();
	rollingFileAppender.setAppend(false);
	rollingFileAppender.setContext(context);
	rollingFileAppender.setEncoder(encoder);
	rollingFileAppender.setFile("logs/" + name + ".log");
	rollingFileAppender.setName(name + "Appender");
	rollingFileAppender.setPrudent(true); // set to true to release the hold
											// of log files.
	rollingFileAppender.setRollingPolicy(timeBasedRollingPolicy);
	rollingFileAppender.setTriggeringPolicy(timeBasedTriggeringPolicy);

	timeBasedRollingPolicy.setParent(rollingFileAppender);

	encoder.start();
	timeBasedRollingPolicy.start();

	rollingFileAppender.stop();
	rollingFileAppender.start();

	Logger logger = context.getLogger(name);
	logger.setLevel(level.convert());
	logger.setAdditive(false);
	logger.addAppender(rollingFileAppender);

	return logger;
}
 
开发者ID:slimsymphony,项目名称:testgrid,代码行数:54,代码来源:LogUtils.java

示例12: main

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
public static void main( String[] args ) {
	// Redirect any libraries' java.util.Logging messages.
	SLF4JBridgeHandler.removeHandlersForRootLogger();
	SLF4JBridgeHandler.install();

	// Doing this here instead of in "logback.xml", allows for conditional log files.
	// For example, the app could decide not to or in a different place.

	// Fork log into a file.
	LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();

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

	FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>();
	fileAppender.setContext( lc );
	fileAppender.setName( "LogFile" );
	fileAppender.setFile( new File( "./modman-log.txt" ).getAbsolutePath() );
	fileAppender.setAppend( false );
	fileAppender.setEncoder( encoder );
	fileAppender.start();

	lc.getLogger( Logger.ROOT_LOGGER_NAME ).addAppender( fileAppender );

	// Log a welcome message.
	log.debug( "Started: {}", new Date() );
	log.debug( "{} v{}", APP_NAME, APP_VERSION );
	log.debug( "OS: {} {}", System.getProperty( "os.name" ), System.getProperty( "os.version" ) );
	log.debug( "VM: {}, {}, {}", System.getProperty( "java.vm.name" ), System.getProperty( "java.version" ), System.getProperty( "os.arch" ) );

	Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
		@Override
		public void uncaughtException( Thread t, Throwable e ) {
			log.error( "Uncaught exception in thread: "+ t.toString(), e );
		}
	});

	if ( args.length > 0 ) {
		SlipstreamCLI.main( args );
		return;
	}

	// Ensure all popups are triggered from the event dispatch thread.

	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			guiInit();
		}
	});
}
 
开发者ID:Vhati,项目名称:Slipstream-Mod-Manager,代码行数:55,代码来源:FTLModManager.java

示例13: initLogs

import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的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.encoder.PatternLayoutEncoder.setCharset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。