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


Java Priority类代码示例

本文整理汇总了Java中org.apache.log4j.Priority的典型用法代码示例。如果您正苦于以下问题:Java Priority类的具体用法?Java Priority怎么用?Java Priority使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: mapLevel

import org.apache.log4j.Priority; //导入依赖的package包/类
private int mapLevel(Level level) {
	switch (level.toInt()) {
	case Priority.DEBUG_INT:
	case Priority.INFO_INT:
		return IStatus.INFO;

	case Priority.WARN_INT:
		return IStatus.WARNING;

	case Priority.ERROR_INT:
	case Priority.FATAL_INT:
		return IStatus.ERROR;

	default:
		return IStatus.INFO;
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:EclipseLogAppender.java

示例2: logStackTrace

import org.apache.log4j.Priority; //导入依赖的package包/类
public void logStackTrace(int traceLevel) {
    if (needsLogging) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        StackTraceElement[] ste = new Exception().getStackTrace();
        // Skip the log writer frame and log all the other stack frames.
        for (int i = 1; i < ste.length; i++) {
            String callFrame = "[" + ste[i].getFileName() + ":"
                    + ste[i].getLineNumber() + "]";
            pw.print(callFrame);
        }
        pw.close();
        String stackTrace = sw.getBuffer().toString();
        Level level = this.getLevel(traceLevel);
        Priority priority = this.getLogPriority();
        if ( level.isGreaterOrEqual(priority)) {
            logger.log(level,stackTrace);
        }

    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:LogWriter.java

示例3: testAutoPopulate

import org.apache.log4j.Priority; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testAutoPopulate ()
{
	final TestClock tc = new TestClock ( 1234567890123L );

	final EcompLayout layout = new EcompLayout ();
	MDC.put ( EcompFields.kBeginTimestampMs, Long.toString ( SaClock.now () ) );

	tc.forward ( 60*1000L );
	layout.format ( new LoggingEvent ( "foo.bar", Category.getRoot (), Priority.INFO, "foobar", null ) );

	assertEquals ( "2009-02-13T23:31:30.123+00:00", MDC.get ( EcompFields.kBeginTimestamp ) );
	assertEquals ( "2009-02-13T23:32:30.123+00:00", MDC.get ( EcompFields.kEndTimestamp ) );
	assertEquals ( "60000", MDC.get ( EcompFields.kElapsedTimeMs ) );
}
 
开发者ID:att,项目名称:dmaap-framework,代码行数:17,代码来源:EcompLayoutTest.java

示例4: LoggingOutputStream

import org.apache.log4j.Priority; //导入依赖的package包/类
/**
 * Creates the LoggingOutputStream to flush to the given Category.
 * 
 * @param cat        the Category to write to
 * 
 * @param priority   the Priority to use when writing to the Category
 * 
 * @exception IllegalArgumentException
 *                   if cat == null or priority == null
 */
public LoggingOutputStream(Category cat, Priority priority)
throws IllegalArgumentException {
  if (cat == null) {
    throw new IllegalArgumentException("cat == null");
  }
  if (priority == null) {
    throw new IllegalArgumentException("priority == null");
  }

  this.priority = priority;
  category = cat;
  bufLength = DEFAULT_BUFFER_LENGTH;
  buf = new byte[DEFAULT_BUFFER_LENGTH];
  count = 0;
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:26,代码来源:LoggingOutputStream.java

示例5: setUp

import org.apache.log4j.Priority; //导入依赖的package包/类
/**
 * @throws Exception
 */
@Before public void setUp() throws Exception {

  new MockUp<Category>() {
    @SuppressWarnings("unused")
    @Mock public boolean isDebugEnabled() {
      return true;
    }

    @SuppressWarnings("unused")
    @Mock public boolean isEnabledFor(Priority level) {
      return true;
    }

    @SuppressWarnings("unused")
    @Mock public boolean isInfoEnabled() {
      return true;
    }
  };

  logService = new StandardLogService(this.getClass().getName());
}
 
开发者ID:carbondata,项目名称:carbondata,代码行数:25,代码来源:StandardLogServiceTest_UT.java

示例6: addIdeFatalMessage

import org.apache.log4j.Priority; //导入依赖的package包/类
@Nullable
public LogMessage addIdeFatalMessage(final IdeaLoggingEvent aEvent) {
  Object data = aEvent.getData();
  final LogMessage message = data instanceof LogMessage ? (LogMessage)data : new LogMessage(aEvent);
  if (myIdeFatals.size() < MAX_POOL_SIZE_FOR_FATALS) {
    if (myFatalsGrouper.addToGroup(message)) {
      return message;
    }
  } else if (myIdeFatals.size() == MAX_POOL_SIZE_FOR_FATALS) {
    String msg = DiagnosticBundle.message("error.monitor.too.many.errors");
    LogMessage tooMany = new LogMessage(new LoggingEvent(msg, Category.getRoot(), Priority.ERROR, null, new TooManyErrorsException()));
    myFatalsGrouper.addToGroup(tooMany);
    return tooMany;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MessagePool.java

示例7: EventDetails

import org.apache.log4j.Priority; //导入依赖的package包/类
/**
 * Creates a new <code>EventDetails</code> instance.
 * @param aTimeStamp a <code>long</code> value
 * @param aPriority a <code>Priority</code> value
 * @param aCategoryName a <code>String</code> value
 * @param aNDC a <code>String</code> value
 * @param aThreadName a <code>String</code> value
 * @param aMessage a <code>String</code> value
 * @param aThrowableStrRep a <code>String[]</code> value
 * @param aLocationDetails a <code>String</code> value
 */
EventDetails(long aTimeStamp,
             Priority aPriority,
             String aCategoryName,
             String aNDC,
             String aThreadName,
             String aMessage,
             String[] aThrowableStrRep,
             String aLocationDetails)
{
    mTimeStamp = aTimeStamp;
    mPriority = aPriority;
    mCategoryName = aCategoryName;
    mNDC = aNDC;
    mThreadName = aThreadName;
    mMessage = aMessage;
    mThrowableStrRep = aThrowableStrRep;
    mLocationDetails = aLocationDetails;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:30,代码来源:EventDetails.java

示例8: testLocationInfoNoFQCN

import org.apache.log4j.Priority; //导入依赖的package包/类
/**
   * Tests LoggingEvent.getLocationInfo() when no FQCN is specified.
   * See bug 41186.
   */
public void testLocationInfoNoFQCN() {
    Category root = Logger.getRootLogger();
 Priority level = Level.INFO;
    LoggingEvent event =
      new LoggingEvent(
        null, root, 0L,  level, "Hello, world.", null);
    LocationInfo info = event.getLocationInformation();
 //
 //  log4j 1.2 returns an object, its layout doesn't check for nulls.
 //  log4j 1.3 returns a null.
 //
 assertNotNull(info);
 if (info != null) {
    assertEquals("?", info.getLineNumber());
 assertEquals("?", info.getClassName());
 assertEquals("?", info.getFileName());
 assertEquals("?", info.getMethodName());
 }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:24,代码来源:LoggingEventTest.java

示例9: run

import org.apache.log4j.Priority; //导入依赖的package包/类
public
   void run() {

     while(true) {
synchronized(this) {
  try {
    this.wait();
  } catch(Exception e) {
  }
}
for(int i = 0; i < burst; i++) {
  LoggingEvent event = new LoggingEvent("x", cat, Priority.DEBUG, 
					"Message "+counter, null);

  event.getThreadName();    
  if(counter % 50 == 0) {
    //event.throwable = new Exception("hello "+counter);
  }
  counter++;
  view.add(event);
}
     }
   }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:24,代码来源:JListView.java

示例10: getIconName

import org.apache.log4j.Priority; //导入依赖的package包/类
/**
 * Extract a reference to the static icon name
 * @param levelInt the int value of the level
 * @return an icon name
 */
private String getIconName() {

	switch (level) {
		case Priority.DEBUG_INT: {
			return ICONS[0];
		}
		case Priority.INFO_INT: {
			return ICONS[1];
		}
		case Priority.WARN_INT: {
			return ICONS[2];
		}
		case Priority.ERROR_INT: {
			return ICONS[3];
		}
		case Priority.FATAL_INT: {
			return ICONS[4];
		}
	}

	return null;
}
 
开发者ID:mongkoy,项目名称:c-logger,代码行数:28,代码来源:LogView4JLoggingEvent.java

示例11: getLevelString

import org.apache.log4j.Priority; //导入依赖的package包/类
/**
 * Extract a reference to the static level strings
 * @param levelInt the int value of the level
 * @return a level string
 */
public String getLevelString() {

	switch (level) {
		case Priority.DEBUG_INT: {
			return LEVELS[0];
		}
		case Priority.INFO_INT: {
			return LEVELS[1];
		}
		case Priority.WARN_INT: {
			return LEVELS[2];
		}
		case Priority.ERROR_INT: {
			return LEVELS[3];
		}
		case Priority.FATAL_INT: {
			return LEVELS[4];
		}
	}

	return null;
}
 
开发者ID:mongkoy,项目名称:c-logger,代码行数:28,代码来源:LogView4JLoggingEvent.java

示例12: getLevelFlag

import org.apache.log4j.Priority; //导入依赖的package包/类
/**
 * Fecth a flag for the current level to enable quick determination in a set of level flags
 * @return the level flag for this log events level
 */
public int getLevelFlag() {
	switch (level) {
		case Priority.DEBUG_INT: {
			return LEVEL_DEBUG_FLAG;
		}
		case Priority.INFO_INT: {
			return LEVEL_INFO_FLAG;
		}
		case Priority.WARN_INT: {
			return LEVEL_WARN_FLAG;
		}
		case Priority.ERROR_INT: {
			return LEVEL_ERROR_FLAG;
		}
		case Priority.FATAL_INT: {
			return LEVEL_FATAL_FLAG;
		}
		default: {
			return 0;
		}
	}
}
 
开发者ID:mongkoy,项目名称:c-logger,代码行数:27,代码来源:LogView4JLoggingEvent.java

示例13: internalInit

import org.apache.log4j.Priority; //导入依赖的package包/类
/**
 *  initializes the log system using the logfile argument
 */
private void internalInit( String logfile )
    throws Exception
{
    /*
     *  do it by our classname to avoid conflicting with anything else 
     *  that might be used...
     */

    logger = Category.getInstance(this.getClass().getName());
    logger.setAdditivity(false);

    /*
     * Priority is set for DEBUG becouse this implementation checks 
     * log level.
     */
    logger.setPriority(Priority.DEBUG);

    RollingFileAppender appender = new RollingFileAppender( new PatternLayout( "%d - %m%n"), logfile, true);
    
    appender.setMaxBackupIndex( 1 );
    
    appender.setMaximumFileSize( 100000 );
    
    logger.addAppender(appender);
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:29,代码来源:SimpleLog4JLogSystem.java

示例14: threadLocalAwareLog

import org.apache.log4j.Priority; //导入依赖的package包/类
/**
 * Logger worker method - does the actual checks whether the given message should be logged at the given priority - taking into account this logger's loglevel plus
 * the threadLocalLogLevel.
 * 
 * @param priority
 *            the priority at which the given message should be logged
 * @param message
 *            the message which should be logged (or not, depending on levels)
 */
private final void threadLocalAwareLog(String fQCN, Priority priority, Object message, Throwable t) {
    if (isForcedToLog(priority)) {

        final Appender forcedAppender = getForcedAppender();

        // force the logging and modify the log message (the latter might return the original message)
        if (forcedAppender != null) {
            // only call the forced appender
            forcedAppender.doAppend(new LoggingEvent(fQCN, this, priority, modifyLogMessage(message), t));
        } else {
            // go via the normal appenders
            forcedLog(fQCN, priority, modifyLogMessage(message), t);
        }

    } else {

        // else not forced to log - use default behaviour
        super.log(fQCN, priority, message, t);

    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:31,代码来源:ThreadLocalAwareLogger.java

示例15: l7dlog

import org.apache.log4j.Priority; //导入依赖的package包/类
@Override
public void l7dlog(Priority priority, String key, Object[] params, Throwable t) {
    if (isForcedToLog(priority)) {
        // from super.l7dlog:
        String pattern = getResourceBundleString(key);
        String msg;
        if (pattern == null)
            msg = key;
        else
            msg = java.text.MessageFormat.format(pattern, params);

        final Appender forcedAppender = getForcedAppender();

        // force the logging and modify the log message (the latter might return the original message)
        if (forcedAppender != null) {
            // only call the forced appender
            forcedAppender.doAppend(new LoggingEvent(FQCN, this, priority, modifyLogMessage(msg), t));
        } else {
            // go via the normal appenders
            forcedLog(FQCN, priority, modifyLogMessage(msg), t);
        }

    } else {
        super.l7dlog(priority, key, params, t);
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:27,代码来源:ThreadLocalAwareLogger.java


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