本文整理汇总了Java中ch.qos.logback.classic.encoder.PatternLayoutEncoder.start方法的典型用法代码示例。如果您正苦于以下问题:Java PatternLayoutEncoder.start方法的具体用法?Java PatternLayoutEncoder.start怎么用?Java PatternLayoutEncoder.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.classic.encoder.PatternLayoutEncoder
的用法示例。
在下文中一共展示了PatternLayoutEncoder.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WebSocketLogAppender
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
public WebSocketLogAppender(String sessionId) {
// deliberately NOT the com.intuit form else will pick up all those
// this is supposed to isolate user-session s
this.sessionId = sessionId;
logger = (Logger) LoggerFactory.getLogger(sessionId);
sb = new StringBuilder();
setName("karate-web");
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
setContext(lc);
encoder = new PatternLayoutEncoder();
encoder.setPattern("%d{HH:mm:ss.SSS} %-5level - %msg%n");
encoder.setContext(context);
encoder.start();
start();
logger.addAppender(this);
logger.setLevel(Level.DEBUG);
}
示例2: configureInMemoryLogging
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
private static void configureInMemoryLogging() {
org.slf4j.Logger rootLogger = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
Logger logbackRootLogger = (Logger) rootLogger;
logbackRootLogger.setLevel(Level.INFO);
OutputStreamAppender<ILoggingEvent> appender = new OutputStreamAppender<>();
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
PatternLayoutEncoder ple = new PatternLayoutEncoder();
ple.setPattern("[%date] [%level] [%logger{10}] %msg%n");
ple.setContext(lc);
ple.start();
try {
ple.init(bos);
} catch (IOException e) {
}
appender.setContext(lc);
appender.setOutputStream(bos);
appender.setName("buffered");
appender.setEncoder(ple);
appender.start();
logbackRootLogger.detachAppender("console");
logbackRootLogger.addAppender(appender);
logbackRootLogger.setAdditive(true);
}
示例3: log
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
@Test
public void log() throws Exception {
Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
LoggerContext context = logger.getLoggerContext();
context.reset();
Map<String, String> ruleRegistry = (Map) context.getObject(CoreConstants.PATTERN_RULE_REGISTRY);
if (ruleRegistry == null) {
ruleRegistry = new HashMap<String, String>();
context.putObject(CoreConstants.PATTERN_RULE_REGISTRY, ruleRegistry);
}
ruleRegistry.put("ex1L", OnelineThrowableProxyConverter.class.getCanonicalName());
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(context);
encoder.setPattern("%d{yyyy/MM/dd HH:mm:ss:SSS}\\t%-5level\\t%msg\\t%ex1L");
encoder.start();
ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
appender.setContext(context);
appender.setEncoder(encoder);
appender.start();
logger.addAppender(appender);
logger.error("error", new RuntimeException("foo"));
}
示例4: log
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
@Test
public void log() throws Exception {
Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
LoggerContext context = logger.getLoggerContext();
context.reset();
Map<String, String> ruleRegistry = (Map) context.getObject(CoreConstants.PATTERN_RULE_REGISTRY);
if (ruleRegistry == null) {
ruleRegistry = new HashMap<String, String>();
context.putObject(CoreConstants.PATTERN_RULE_REGISTRY, ruleRegistry);
}
ruleRegistry.put("xEx1L", OnelineExtendedThrowableProxyConverter.class.getCanonicalName());
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(context);
encoder.setPattern("%d{yyyy/MM/dd HH:mm:ss:SSS}\\t%-5level\\t%msg\\t%xEx1L");
encoder.start();
ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
appender.setContext(context);
appender.setEncoder(encoder);
appender.start();
logger.addAppender(appender);
logger.error("error", new RuntimeException());
}
开发者ID:roundrop,项目名称:logback-oneline-converter,代码行数:27,代码来源:OnelineExtendedThrowableProxyConverterTest.java
示例5: addFileAppender
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
/**
* Add a specific appender meant for FILE.
*/
public static void addFileAppender ()
{
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(
Logger.ROOT_LOGGER_NAME);
FileAppender fileAppender = new FileAppender();
PatternLayoutEncoder fileEncoder = new PatternLayoutEncoder();
fileAppender.setName("FILE");
fileAppender.setContext(loggerContext);
fileAppender.setAppend(false);
String now = new SimpleDateFormat("yyyyMMdd'T'HHmmss").format(new Date());
Path logPath = WellKnowns.LOG_FOLDER.resolve(now + ".log").toAbsolutePath();
fileAppender.setFile(logPath.toString());
fileEncoder.setContext(loggerContext);
fileEncoder.setPattern("%date %-5level [%X{BOOK}%X{SHEET}] %25replace(%file){'\\.java$',''} %-4line | %msg%n%ex");
fileEncoder.start();
fileAppender.setEncoder(fileEncoder);
fileAppender.start();
root.addAppender(fileAppender);
System.out.println("LogUtil. Logging to " + logPath);
}
示例6: buildFileAppender
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
public FileAppender<ILoggingEvent> buildFileAppender(LoggerContext context, String file) {
FileAppender<ILoggingEvent> fileAppender = new FileAppender<>();
fileAppender.setFile(file);
fileAppender.setContext(context);
fileAppender.setPrudent(true);
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(context);
encoder.setPattern(primaryConfiguration.getLoggingPattern().or(baseConfiguration.getLoggingPattern()).or(JavaUtils.LOGBACK_LOGGING_PATTERN));
encoder.start();
fileAppender.setEncoder(encoder);
fileAppender.start();
return fileAppender;
}
示例7: logToFile
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
static void logToFile(Parameters parameters) {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
PatternLayoutEncoder ple = new PatternLayoutEncoder();
ple.setPattern("%date %level [%thread] %logger{10} [%file:%line] %msg%n");
ple.setContext(lc);
ple.start();
FileAppender<ILoggingEvent> fileAppender = new FileAppender<>();
fileAppender.setFile(parameters.getWorkingDirectory() + "/jlineup.log");
fileAppender.setEncoder(ple);
fileAppender.setContext(lc);
fileAppender.start();
ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
logger.addAppender(fileAppender);
logger.setLevel(Level.DEBUG);
}
示例8: createLogger
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
private Logger createLogger(File logFile) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
ch.qos.logback.classic.Logger log = loggers.get();
log.setAdditive(false);
FileAppender fileAppender = new FileAppender();
fileAppender.setContext(context);
fileAppender.setName(Thread.currentThread().getName());
fileAppender.setFile(logFile.getAbsolutePath());
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(context);
encoder.setPattern(LOG_PATTERN);
encoder.start();
fileAppender.setEncoder(encoder);
fileAppender.start();
log.detachAndStopAllAppenders();
log.addAppender(fileAppender);
return log;
}
示例9: build
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
@Override
public Appender<ILoggingEvent> build(LoggerContext context, String s, Layout<ILoggingEvent> layout) {
Preconditions.checkNotNull(context);
WiretapAppender appender = new WiretapAppender();
final PatternLayoutEncoder patternEncoder = new PatternLayoutEncoder();
patternEncoder.setContext(context);
patternEncoder.setPattern("%-5p [%thread] [%d] %c: %m%n%rEx");
patternEncoder.start();
appender.setContext(context);
appender.setName("wiretap-appender");
appender.setEncoder(patternEncoder);
addThresholdFilter(appender, threshold);
appender.start();
return wrapAsync(appender);
}
示例10: configure
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
/**
* Initializes the logger and the requested log level.
*
* @param level Logging level threshold
*/
@SuppressWarnings("unchecked")
public static void configure(final Level level) {
final Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(level);
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(root.getLoggerContext());
encoder.setPattern("%msg%n");
encoder.start();
Iterator<Appender<ILoggingEvent>> iterator = root.iteratorForAppenders();
while (iterator.hasNext()) {
Appender<ILoggingEvent> appender = iterator.next();
if (appender instanceof OutputStreamAppender) {
((OutputStreamAppender) appender).setEncoder(encoder);
}
appender.stop();
appender.start();
}
}
示例11: TmmUILogCollector
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
private TmmUILogCollector() {
Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
// create a new TmmUILogAppender - so we need not to put it in the logback.xml:
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(rootLogger.getLoggerContext());
encoder.setPattern("%d{HH:mm:ss.SSS} %-5level %logger{60} - %msg%n");
encoder.start();
logAppender = new TmmUILogAppender();
logAppender.setContext(rootLogger.getLoggerContext());
logAppender.setEncoder(encoder);
logAppender.start();
rootLogger.addAppender(logAppender);
}
示例12: createLogger
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
/**
* Creates a new logger.
*
* @param name a name for the logger
* @param level the logging level for the logger
* @param file the file to output all logging to
* @return the created logger
*/
public static Logger createLogger(String name, Level level, String file) {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
PatternLayoutEncoder ple = new PatternLayoutEncoder();
ple.setPattern("%date %level [%thread] %logger{10} [%file:%line]%n%msg%n%n");
ple.setContext(lc);
ple.start();
FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>();
fileAppender.setFile(file);
fileAppender.setEncoder(ple);
fileAppender.setAppend(false);
fileAppender.setContext(lc);
fileAppender.start();
logger = (Logger) LoggerFactory.getLogger(name);
logger.detachAndStopAllAppenders(); // detach console (doesn't seem to work)
logger.addAppender(fileAppender); // attach file appender
logger.setLevel(level);
logger.setAdditive(true); // set to true if root should log too
return logger;
}
示例13: 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;
}
示例14: getTestCaseLogger
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
/**
* Finds or creates a logger for the test case called tcName with an appender writing
* to file named <tcName>.log
*
* @param tcName
* @return
*/
private Logger getTestCaseLogger(String tcName, String sutName, String sutDir, String testScheduleName) {
FileAppender<ILoggingEvent> fileAppender = appenderMap.get(tcName);
if (fileAppender == null) {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
PatternLayoutEncoder ple = new PatternLayoutEncoder();
ple.setPattern("%date %level [%logger{36}] [%file:%line] %X{testcase}: %msg%n");
ple.setContext(lc);
ple.start();
fileAppender = new FileAppender<ILoggingEvent>();
fileAppender.setFile(sutDir + '/' + testScheduleName + '/' + tcName + ".log");
fileAppender.setEncoder(ple);
fileAppender.setContext(lc);
fileAppender.start();
appenderMap.put(tcName, fileAppender);
}
Logger logger = (Logger) LoggerFactory.getLogger(tcName);
logger.addAppender(fileAppender);
return logger;
}
示例15: buildLoggerContext
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; //导入方法依赖的package包/类
static Logger buildLoggerContext(LoggerContext lc) {
Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
PatternLayoutEncoder patternLayout = new PatternLayoutEncoder();
patternLayout.setContext(lc);
patternLayout.setPattern("%d %l [%t] - %msg%n");
patternLayout.start();
FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>();
fileAppender.setContext(lc);
fileAppender.setFile("target/lbclassic135.log");
fileAppender.setEncoder(patternLayout);
fileAppender.setAppend(false);
fileAppender.start();
root.addAppender(fileAppender);
return lc.getLogger(LoggingToFileThroughput.class);
}