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


Java PropertiesUtil.getStringProperty方法代码示例

本文整理汇总了Java中org.apache.logging.log4j.util.PropertiesUtil.getStringProperty方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesUtil.getStringProperty方法的具体用法?Java PropertiesUtil.getStringProperty怎么用?Java PropertiesUtil.getStringProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.logging.log4j.util.PropertiesUtil的用法示例。


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

示例1: SimpleLogger

import org.apache.logging.log4j.util.PropertiesUtil; //导入方法依赖的package包/类
public SimpleLogger(final String name, final Level defaultLevel, final boolean showLogName,
                    final boolean showShortLogName, final boolean showDateTime, final boolean showContextMap,
                    final String dateTimeFormat, final MessageFactory messageFactory, final PropertiesUtil props,
                    final PrintStream stream) {
    super(name, messageFactory);
    final String lvl = props.getStringProperty(SimpleLoggerContext.SYSTEM_PREFIX + name + ".level");
    this.level = Level.toLevel(lvl, defaultLevel);
    if (showShortLogName) {
        final int index = name.lastIndexOf(".");
        if (index > 0 && index < name.length()) {
            this.logName = name.substring(index + 1);
        } else {
            this.logName = name;
        }
    } else if (showLogName) {
        this.logName = name;
    } else {
    	this.logName = null;
    }
    this.showDateTime = showDateTime;
    this.showContextMap = showContextMap;
    this.stream = stream;

    if (showDateTime) {
        try {
            this.dateFormatter = new SimpleDateFormat(dateTimeFormat);
        } catch (final IllegalArgumentException e) {
            // If the format pattern is invalid - use the default format
            this.dateFormatter = new SimpleDateFormat(SimpleLoggerContext.DEFAULT_DATE_TIME_FORMAT);
        }
    }
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:33,代码来源:SimpleLogger.java

示例2: SimpleLoggerContext

import org.apache.logging.log4j.util.PropertiesUtil; //导入方法依赖的package包/类
public SimpleLoggerContext() {
    props = new PropertiesUtil("log4j2.simplelog.properties");

    showContextMap = props.getBooleanProperty(SYSTEM_PREFIX + "showContextMap", false);
    showLogName = props.getBooleanProperty(SYSTEM_PREFIX + "showlogname", false);
    showShortName = props.getBooleanProperty(SYSTEM_PREFIX + "showShortLogname", true);
    showDateTime = props.getBooleanProperty(SYSTEM_PREFIX + "showdatetime", false);
    final String lvl = props.getStringProperty(SYSTEM_PREFIX + "level");
    defaultLevel = Level.toLevel(lvl, Level.ERROR);

    dateTimeFormat = showDateTime ? props.getStringProperty(SimpleLoggerContext.SYSTEM_PREFIX + "dateTimeFormat",
            DEFAULT_DATE_TIME_FORMAT) : null;

    final String fileName = props.getStringProperty(SYSTEM_PREFIX + "logFile", "system.err");
    PrintStream ps;
    if ("system.err".equalsIgnoreCase(fileName)) {
        ps = System.err;
    } else if ("system.out".equalsIgnoreCase(fileName)) {
        ps = System.out;
    } else {
        try {
            final FileOutputStream os = new FileOutputStream(fileName);
            ps = new PrintStream(os);
        } catch (final FileNotFoundException fnfe) {
            ps = System.err;
        }
    }
    this.stream = ps;
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:30,代码来源:SimpleLoggerContext.java

示例3: SimpleLogger

import org.apache.logging.log4j.util.PropertiesUtil; //导入方法依赖的package包/类
public SimpleLogger(final String name, final Level defaultLevel, final boolean showLogName,
        final boolean showShortLogName, final boolean showDateTime, final boolean showContextMap,
        final String dateTimeFormat, final MessageFactory messageFactory, final PropertiesUtil props,
        final PrintStream stream) {
    super(name, messageFactory);
    final String lvl = props.getStringProperty(SimpleLoggerContext.SYSTEM_PREFIX + name + ".level");
    this.level = Level.toLevel(lvl, defaultLevel);
    if (showShortLogName) {
        final int index = name.lastIndexOf(".");
        if (index > 0 && index < name.length()) {
            this.logName = name.substring(index + 1);
        } else {
            this.logName = name;
        }
    } else if (showLogName) {
        this.logName = name;
    } else {
        this.logName = null;
    }
    this.showDateTime = showDateTime;
    this.showContextMap = showContextMap;
    this.stream = stream;

    if (showDateTime) {
        DateFormat format;
        try {
            format = new SimpleDateFormat(dateTimeFormat);
        } catch (final IllegalArgumentException e) {
            // If the format pattern is invalid - use the default format
            format = new SimpleDateFormat(SimpleLoggerContext.DEFAULT_DATE_TIME_FORMAT);
        }
        this.dateFormatter = format;
    } else {
        this.dateFormatter = null;
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:37,代码来源:SimpleLogger.java

示例4: SimpleLoggerContext

import org.apache.logging.log4j.util.PropertiesUtil; //导入方法依赖的package包/类
public SimpleLoggerContext() {
    props = new PropertiesUtil("log4j2.simplelog.properties");

    showContextMap = props.getBooleanProperty(SYSTEM_PREFIX + "showContextMap", false);
    showLogName = props.getBooleanProperty(SYSTEM_PREFIX + "showlogname", false);
    showShortName = props.getBooleanProperty(SYSTEM_PREFIX + "showShortLogname", true);
    showDateTime = props.getBooleanProperty(SYSTEM_PREFIX + "showdatetime", false);
    final String lvl = props.getStringProperty(SYSTEM_PREFIX + "level");
    defaultLevel = Level.toLevel(lvl, Level.ERROR);

    dateTimeFormat = showDateTime ? props.getStringProperty(SimpleLoggerContext.SYSTEM_PREFIX + "dateTimeFormat",
            DEFAULT_DATE_TIME_FORMAT) : null;

    final String fileName = props.getStringProperty(SYSTEM_PREFIX + "logFile", SYSTEM_ERR);
    PrintStream ps;
    if (SYSTEM_ERR.equalsIgnoreCase(fileName)) {
        ps = System.err;
    } else if (SYSTEM_OUT.equalsIgnoreCase(fileName)) {
        ps = System.out;
    } else {
        try {
            final FileOutputStream os = new FileOutputStream(fileName);
            ps = new PrintStream(os);
        } catch (final FileNotFoundException fnfe) {
            ps = System.err;
        }
    }
    this.stream = ps;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:30,代码来源:SimpleLoggerContext.java

示例5: createDiscardingAsyncQueueFullPolicy

import org.apache.logging.log4j.util.PropertiesUtil; //导入方法依赖的package包/类
private static AsyncQueueFullPolicy createDiscardingAsyncQueueFullPolicy() {
    final PropertiesUtil util = PropertiesUtil.getProperties();
    final String level = util.getStringProperty(PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL, Level.INFO.name());
    final Level thresholdLevel = Level.toLevel(level, Level.INFO);
    LOGGER.debug("Creating custom DiscardingAsyncQueueFullPolicy(discardThreshold:{})", thresholdLevel);
    return new DiscardingAsyncQueueFullPolicy(thresholdLevel);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:8,代码来源:AsyncQueueFullPolicyFactory.java

示例6: initPrivate

import org.apache.logging.log4j.util.PropertiesUtil; //导入方法依赖的package包/类
/**
 * Initializes static variables based on system properties. Normally called when this class is initialized by the VM
 * and when Log4j is reconfigured.
 */
private static void initPrivate() {
    final PropertiesUtil properties = PropertiesUtil.getProperties();
    ThreadContextMapName = properties.getStringProperty(THREAD_CONTEXT_KEY);
    GcFreeThreadContextKey = properties.getBooleanProperty(GC_FREE_THREAD_CONTEXT_KEY);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:10,代码来源:ThreadContextMapFactory.java


注:本文中的org.apache.logging.log4j.util.PropertiesUtil.getStringProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。