本文整理汇总了Java中org.apache.log4j.helpers.PatternConverter类的典型用法代码示例。如果您正苦于以下问题:Java PatternConverter类的具体用法?Java PatternConverter怎么用?Java PatternConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PatternConverter类属于org.apache.log4j.helpers包,在下文中一共展示了PatternConverter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import org.apache.log4j.helpers.PatternConverter; //导入依赖的package包/类
/**
Produces a formatted string as specified by the conversion pattern.
*/
public String format(LoggingEvent event) {
// Reset working stringbuffer
if(sbuf.capacity() > MAX_CAPACITY) {
sbuf = new StringBuffer(BUF_SIZE);
} else {
sbuf.setLength(0);
}
PatternConverter c = head;
while(c != null) {
c.format(sbuf, event);
c = c.next;
}
return sbuf.toString();
}
示例2: finalizeConverter
import org.apache.log4j.helpers.PatternConverter; //导入依赖的package包/类
@Override
protected void finalizeConverter(char c) {
PatternConverter pc = null;
switch (c) {
case 'H':
pc = new HeaderPatternConverter(formattingInfo);
currentLiteral.setLength(0);
break;
}
if (pc != null) {
addConverter(pc);
} else {
super.finalizeConverter(c);
}
}
示例3: finalizeConverter
import org.apache.log4j.helpers.PatternConverter; //导入依赖的package包/类
/**
* @param c
* @see org.apache.log4j.helpers.PatternParser#finalizeConverter(char)
*/
@Override
protected void finalizeConverter(final char c)
{
switch (c)
{
case 'm':
{
final PatternConverter pc = new EscapedMessagePatternConverter(
formattingInfo);
// LogLog.debug("MESSAGE converter.");
// formattingInfo.dump();
currentLiteral.setLength(0);
addConverter(pc);
break;
}
default:
{
super.finalizeConverter(c);
break;
}
}
}
示例4: format
import org.apache.log4j.helpers.PatternConverter; //导入依赖的package包/类
/**
Produces a formatted string as specified by the conversion pattern.
*/
public String format(LoggingEvent event) {
// Reset working stringbuffer
if(sbuf.capacity() > MAX_CAPACITY) {
sbuf = new StringBuffer(BUF_SIZE);
} else {
sbuf.setLength(0);
}
PatternConverter c = head;
while(c != null) {
c.format(sbuf, event);
c = c.next;
}
return sbuf.toString();
}
示例5: format
import org.apache.log4j.helpers.PatternConverter; //导入依赖的package包/类
/**
* Formats a logging event to a writer.
*
* @param event
* logging event to be formatted.
*/
public String format(final LoggingEvent event) {
final StringBuffer buf = new StringBuffer();
for (PatternConverter c = head; c != null; c = c.next) {
c.format(buf, event);
}
return buf.toString();
}
示例6: format
import org.apache.log4j.helpers.PatternConverter; //导入依赖的package包/类
/**
* Formats a logging event to a writer.
* @param event logging event to be formatted.
*/
public String format(final LoggingEvent event) {
StringBuffer buf = new StringBuffer();
for(PatternConverter c = head;
c != null;
c = c.next) {
c.format(buf, event);
}
return buf.toString();
}
示例7: FoundationLoggingPatternConverter
import org.apache.log4j.helpers.PatternConverter; //导入依赖的package包/类
/**
* Create a new instance.
*
* @param pattern
* pattern, may not be null.
*/
public FoundationLoggingPatternConverter(final String pattern) {
super();
next = null;
handlesExceptions = false;
final List<PatternConverter> converters = new ArrayList<PatternConverter>();
final List<FormattingInfo> fields = new ArrayList<FormattingInfo>();
@SuppressWarnings("unchecked")
final Map converterRegistry = null;
@SuppressWarnings("unchecked")
final Map<String, Class<? extends org.apache.log4j.pattern.PatternConverter>> patternLayoutRules = PatternParser.getPatternLayoutRules();
final Map<String, Class<? extends org.apache.log4j.pattern.PatternConverter>> newPatternLayoutRules = new HashMap<String, Class<? extends org.apache.log4j.pattern.PatternConverter>>();
newPatternLayoutRules.putAll(patternLayoutRules);
newPatternLayoutRules.put("throwable", FoundationLoggingThrowableInformationPatternConverter.class);
newPatternLayoutRules.put("pm", FoundationLoggingMessagePatternConverter.class);
newPatternLayoutRules.put("sl", FoundationLoggingStructuredMessageConverter.class);
newPatternLayoutRules.put("prettymessage", FoundationLoggingMessagePatternConverter.class);
newPatternLayoutRules.put("errorcode", FoundationLoggingErrorCodePatternConverter.class);
newPatternLayoutRules.put("audit", FoundationLoggingAuditPatternConverter.class);
newPatternLayoutRules.put("u", FoundationLoggingUserFieldPatternConverter.class);
newPatternLayoutRules.put("host", FoundationLoggingHostPatternConverter.class);
newPatternLayoutRules.put("compInstallPath", FoundationLoggingCompInstPathPatternConverter.class);
newPatternLayoutRules.put("compVersion", FoundationLoggingCompVersionPatternConverter.class);
newPatternLayoutRules.put("compName", FoundationLoggingCompNamePatternConverter.class);
newPatternLayoutRules.put("compInstanceName", FoundationLoggingCompInstNamePatternConverter.class);
PatternParser.parse(pattern, converters, fields, converterRegistry, newPatternLayoutRules);
patternConverters = new LoggingEventPatternConverter[converters.size()];
patternFields = new FormattingInfo[converters.size()];
int index = 0;
final Iterator<PatternConverter> converterIter = converters.iterator();
final Iterator<FormattingInfo> fieldIter = fields.iterator();
while (converterIter.hasNext()) {
final Object converter = converterIter.next();
if (converter instanceof LoggingEventPatternConverter) {
patternConverters[index] = (LoggingEventPatternConverter) converter;
handlesExceptions |= patternConverters[index].handlesThrowable();
} else {
patternConverters[index] = new org.apache.log4j.pattern.LiteralPatternConverter("");
}
if (fieldIter.hasNext()) {
patternFields[index] = fieldIter.next();
} else {
patternFields[index] = FormattingInfo.getDefault();
}
index++;
}
}