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


Java LoggingEvent.getMessage方法代码示例

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


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

示例1: getLoggingMesage

import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
private String getLoggingMesage( LoggingEvent event ) {

        Throwable throwable = null;
        ThrowableInformation throwableInfo = event.getThrowableInformation();
        if (throwableInfo != null && throwableInfo.getThrowable() != null) {
            // logging through methods like error(new Exception);
            throwable = throwableInfo.getThrowable();
        } else if (event.getMessage() instanceof Throwable) {
            // logging through methods like error("some message", new Exception);
            throwable = (Throwable) event.getMessage();
        }

        // first format the message using the layout
        String message = layout.format(event);
        // then append the exception stack trace
        if (throwable != null) {
            message = getExceptionMsg(throwable, message);
        }

        return message;

    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:23,代码来源:DbEventRequestProcessor.java

示例2: append

import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
public void append(LoggingEvent event) {
    boolean displayIsFine = display == null || display.isDisposed();
    boolean parentIsFine = parent == null || parent.isDisposed();
    if(displayIsFine || parentIsFine || text == null) {
        return;
    }
    DateFormat dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.FULL, locale);
    Date time = new Date(event.getTimeStamp());
    String dateTime = dateTimeFormat.format(time);
    String excMessage;
    Object message = event.getMessage();
    if (message instanceof String) {
        excMessage = (String) message;
    } else {
        return;
    }
    final String logMessage = String.format("[%s] %s%n", dateTime, excMessage);
    parent.getDisplay().asyncExec(() -> {
        if (!text.isDisposed()) {
            text.append(logMessage);
        }
    });
}
 
开发者ID:technology16,项目名称:pgsqlblocks,代码行数:25,代码来源:UIAppender.java

示例3: FastLoggingEvent

import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
public FastLoggingEvent(LoggingEvent event, int stackOffset) {
    super(event.getFQNOfLoggerClass(),
          event.getLogger(),
          event.getLevel(),
          event.getMessage(),
          (event.getThrowableInformation() != null ? event.getThrowableInformation().getThrowable() : null));
    this.event = event;
    this.stackOffset = stackOffset;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:10,代码来源:FastLoggingEvent.java

示例4: defaultLogFormat

import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
static private Object defaultLogFormat(LoggingEvent loggingEvent) {

        LoggingEventX eventX = new LoggingEventX(loggingEvent.getFQNOfLoggerClass(), loggingEvent.getLogger()
                , loggingEvent.getTimeStamp(), loggingEvent.getLevel(), loggingEvent.getMessage(),
                loggingEvent.getThreadName(), loggingEvent.getThrowableInformation(), loggingEvent.getNDC(),
                loggingEvent.getLocationInformation(), loggingEvent.getProperties());

        eventX.setLogTime(new Date(loggingEvent.getTimeStamp()));
        eventX.setLogLevel(eventX.getLevel().toString());
        return eventX;
    }
 
开发者ID:Crab2died,项目名称:log4j-redis-appender,代码行数:12,代码来源:RedisAppender.java

示例5: serializeLoggingEvent

import org.apache.log4j.spi.LoggingEvent; //导入方法依赖的package包/类
private String serializeLoggingEvent(LoggingEvent loggingEvent, Log4jALAAppender appender)
		throws JsonProcessingException {
	// http://stackoverflow.com/questions/11294307/convert-java-date-to-utc-string
	String ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS zzz";
	SimpleDateFormat sdf = new SimpleDateFormat(ISO_FORMAT);
	sdf.setTimeZone(TimeZone.getTimeZone("UTC"));

	HashMap<String, Object> payload = new HashMap<String, Object>();
	
	Object logMessage = loggingEvent.getMessage();

	if (!StringUtils.isEmpty(appender.getEnvironment()) && !StringUtils.isEmpty(appender.getComponent())
			&& !StringUtils.isEmpty(appender.getVersion())
			&& !jsonMapper.writeValueAsString(logMessage).toLowerCase().contains("component")
			&& !jsonMapper.writeValueAsString(logMessage).toLowerCase().contains("environment")
			&& !jsonMapper.writeValueAsString(logMessage).toLowerCase().contains("version")) {
		HashMap<String, Object> message = new HashMap<String, Object>();
		message.put("Component", appender.getComponent());
		message.put("Version", appender.getVersion());
		message.put("Environment", appender.getEnvironment());
		message.put("Message", logMessage);
		message.put("Source", "");
		message.put("SequenceId", "");
		message.put("ScriptName", "");
		payload.put("LogMessage", message);
	}else{
		payload.put("LogMessage", logMessage);
	}

	payload.put("DateValue", sdf.format(new Date(loggingEvent.timeStamp)));
	
	if(appender.getAppendLogger()){
		payload.put("Logger", loggingEvent.getLoggerName());
	}
	
	if(appender.getAppendLogLevel() && loggingEvent.getLevel() != null){
		payload.put("Level", loggingEvent.getLevel().toString().toUpperCase());
	}

	return jsonMapper.writeValueAsString(payload);
}
 
开发者ID:ptv-logistics,项目名称:Log4jALA,代码行数:42,代码来源:LoggingEventSerializer.java


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