當前位置: 首頁>>代碼示例>>Java>>正文


Java Logger類代碼示例

本文整理匯總了Java中org.slf4j.Logger的典型用法代碼示例。如果您正苦於以下問題:Java Logger類的具體用法?Java Logger怎麽用?Java Logger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Logger類屬於org.slf4j包,在下文中一共展示了Logger類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: signObject

import org.slf4j.Logger; //導入依賴的package包/類
/**
 * Signs a single XMLObject.
 * 
 * @param signature the signature to computer the signature on
 * @throws SignatureException thrown if there is an error computing the signature
 */
public static void signObject(Signature signature) throws SignatureException {
    Logger log = getLogger();
    try {
        XMLSignature xmlSignature = ((SignatureImpl) signature).getXMLSignature();

        if (xmlSignature == null) {
            log.error("Unable to compute signature, Signature XMLObject does not have the XMLSignature "
                    + "created during marshalling.");
            throw new SignatureException("XMLObject does not have an XMLSignature instance, unable to compute signature");
        }
        log.debug("Computing signature over XMLSignature object");
        xmlSignature.sign(SecurityHelper.extractSigningKey(signature.getSigningCredential()));
    } catch (XMLSecurityException e) {
        log.error("An error occured computing the digital signature", e);
        throw new SignatureException("Signature computation error", e);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:Signer.java

示例2: listWithoutPath

import org.slf4j.Logger; //導入依賴的package包/類
public static List<String> listWithoutPath(List<String> listWithPrefix, String fixedPath,  Logger log)
{
	final List<String> listWithoutFixedPath;
	listWithoutFixedPath= new ArrayList<String>();
	for (String resourcePath : listWithPrefix)
	{
		if (StringUtils.isNotEmpty(resourcePath))
			if (resourcePath.startsWith(fixedPath))
				listWithoutFixedPath.add(resourcePath.substring(fixedPath.length()));
			else
				log.warn(String.format("Invalid starting path %s, expected to begin with %s", resourcePath, fixedPath));
		else
			log.warn(String.format("Empty path %s", resourcePath));
	}
	return listWithoutFixedPath;
}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:17,代碼來源:ResourceHelper.java

示例3: validateResource

import org.slf4j.Logger; //導入依賴的package包/類
public static void validateResource(String resourcePath,Logger log) 
{ 

	ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
	try {
		if (resourceResolver.getResources("classpath*:/GameData" +resourcePath+"*").length==0)
			log.error("INEXISTENT RESOURCE "+"/GameData" +resourcePath+"*");
	} catch (IOException e) {
		// TODO Auto-generated catch block 
		e.printStackTrace();
	}
}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:13,代碼來源:ResourceHelper.java

示例4: getRequestJsonObject

import org.slf4j.Logger; //導入依賴的package包/類
private JsonObject getRequestJsonObject(Logger logger, boolean logFailedRequests) {
    JsonObject chart = new JsonObject();
    chart.addProperty("chartId", chartId);
    try {
        JsonObject data = getChartData();
        if (data == null) {
            // If the data is null we don't send the chart.
            return null;
        }
        chart.add("data", data);
    } catch (Throwable t) {
        if (logFailedRequests) {
            logger.warn("Failed to get data for custom chart with id {}", chartId, t);
        }
        return null;
    }
    return chart;
}
 
開發者ID:codeHusky,項目名稱:HuskyUI-Plugin,代碼行數:19,代碼來源:Metrics.java

示例5: decode_set_vlan_id

import org.slf4j.Logger; //導入依賴的package包/類
/**
 * Parse set_vlan_id actions.
 * The key and delimiter for the action should be omitted, and only the
 * data should be presented to this decoder. Data with a leading 0x is permitted.
 * 
 * @param actionToDecode; The action as a string to decode
 * @param version; The OF version to create the action for
 * @param log
 * @return
 */
private static OFActionSetVlanVid decode_set_vlan_id(String actionToDecode, OFVersion version, Logger log) {
	Matcher n = Pattern.compile("((?:0x)?\\d+)").matcher(actionToDecode);
	if (n.matches()) {            
		if (n.group(1) != null) {
			try {
				VlanVid vlanid = VlanVid.ofVlan(get_short(n.group(1)));
				OFActionSetVlanVid.Builder ab = OFFactories.getFactory(version).actions().buildSetVlanVid();
				ab.setVlanVid(vlanid);
				log.debug("action {}", ab.build());
				return ab.build();
			}
			catch (NumberFormatException e) {
				log.debug("Invalid VLAN in: {} (error ignored)", actionToDecode);
				return null;
			}
		}          
	}
	else {
		log.debug("Invalid action: '{}'", actionToDecode);
		return null;
	}
	return null;
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:34,代碼來源:ActionUtils.java

示例6: decode_set_tos_bits

import org.slf4j.Logger; //導入依賴的package包/類
/**
 * Parse set_tos actions.
 * The key and delimiter for the action should be omitted, and only the
 * data should be presented to this decoder. A leading 0x is permitted.
 * 
 * @param actionToDecode; The action as a string to decode
 * @param version; The OF version to create the action for
 * @param log
 * @return
 */
private static OFActionSetNwTos decode_set_tos_bits(String actionToDecode, OFVersion version, Logger log) {
	Matcher n = Pattern.compile("((?:0x)?\\d+)").matcher(actionToDecode); 
	if (n.matches()) {
		if (n.group(1) != null) {
			try {
				byte tosbits = get_byte(n.group(1));
				OFActionSetNwTos.Builder ab = OFFactories.getFactory(version).actions().buildSetNwTos();
				ab.setNwTos(tosbits);
				log.debug("action {}", ab.build());
				return ab.build();
			}
			catch (NumberFormatException e) {
				log.debug("Invalid dst-port in: {} (error ignored)", actionToDecode);
				return null;
			}
		}
	}
	else {
		log.debug("Invalid action: '{}'", actionToDecode);
		return null;
	}
	return null;
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:34,代碼來源:ActionUtils.java

示例7: NettyClientHandler

import org.slf4j.Logger; //導入依賴的package包/類
public NettyClientHandler(String id, int epoch, String protocol, int affinity, T login, Integer connTimeout, long idleTimeout,
    Logger log, NettyMetricsSink metrics, NettyClient<T> client, NetworkClientCallback<T> callback) {
    this.log = log;
    this.id = id;
    this.epoch = epoch;
    this.protocol = protocol;
    this.affinity = affinity;
    this.login = login;
    this.idleTimeout = idleTimeout;
    this.connTimeout = connTimeout;
    this.metrics = metrics;
    this.client = client;
    this.callback = callback;

    this.debug = log.isDebugEnabled();
    this.trace = log.isTraceEnabled();

    hbOnFlush = future -> {
        hbFlushed = true;

        if (!future.isSuccess() && future.channel().isOpen()) {
            future.channel().pipeline().fireExceptionCaught(future.cause());
        }
    };
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:26,代碼來源:NettyClientHandler.java

示例8: logsAndExecutesSteps

import org.slf4j.Logger; //導入依賴的package包/類
/**
 * GithubSteps logs the received comment and author and
 * executes the given steps.
 * @throws Exception If something goes wrong.
 */
@Test
public void logsAndExecutesSteps() throws Exception {
    final Command comment = Mockito.mock(Command.class);
    Mockito.when(comment.json()).thenReturn(
        Json.createObjectBuilder().add("body", "@comdor run").build()
    );
    Mockito.when(comment.author()).thenReturn("amihaiemil");
    final Step toExecute = Mockito.mock(Step.class);
    
    final Steps steps = new GithubSteps(toExecute, comment);
    
    final Log log = Mockito.mock(Log.class);
    final Logger slf4j = Mockito.mock(Logger.class);
    Mockito.when(log.logger()).thenReturn(slf4j);
    
    steps.perform(log);
    
    Mockito.verify(slf4j).info("Received command: @comdor run");
    Mockito.verify(slf4j).info("Author login: amihaiemil");
    Mockito.verify(toExecute).perform(comment, log);
}
 
開發者ID:amihaiemil,項目名稱:comdor,代碼行數:27,代碼來源:GithubStepsTestCase.java

示例9: logHistorySteps

import org.slf4j.Logger; //導入依賴的package包/類
/** 
 *  Write out the state the all the history steps. 
 */

public static void logHistorySteps(Logger logger, long piid, OSWfEngine wfEngine) {
        
    List<Step> steps = wfEngine.getHistorySteps(piid);
    WorkflowDescriptor wfDescriptor = wfEngine.getWorkflowDescriptor(wfEngine.getWorkflowName(piid));

    if(steps.size() > 0) 
        for (Step step : steps) 
            logger.debug(String.format("History Step: %3d %-20s %s  ",   // %3s-%3s
                step.getStepId(),
                wfDescriptor.getStep(step.getStepId()).getName(),
                step.getStatus()
                // dateFormatter.format(step.getStartDate()),
                // dateFormatter.format(step.getFinishDate())
            ));
   else
        logger.debug("No available history steps");
}
 
開發者ID:will-gilbert,項目名稱:OSWf-OSWorkflow-fork,代碼行數:22,代碼來源:OSWfLogging.java

示例10: pluginHealthCheck

import org.slf4j.Logger; //導入依賴的package包/類
protected void pluginHealthCheck() {
    ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();

    scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {
        private final Logger CHECKLOGGER = LoggerFactory.getLogger(AbstractPluginManager.class);

        @Override
        public void run() {
            for (Plugin p : context.getPluginMap().values()) {
                if (p.getStatus().equals(PluginStatus.ERROR)) {
                    CHECKLOGGER.error("HEALTH CHECK - Plugin {} is in error.", p.getName());
                    p.disable();
                }
            }
        }
    }, 0, 1, TimeUnit.SECONDS);
}
 
開發者ID:MatteoJoliveau,項目名稱:PlugFace,代碼行數:18,代碼來源:AbstractPluginManager.java

示例11: createRegisterLogger

import org.slf4j.Logger; //導入依賴的package包/類
public static Slf4jDdsLogger createRegisterLogger() throws IOException {
  // create logger
  Slf4jDdsLogger slf4jDdsLogger = new Slf4jDdsLogger();

  // register logger
  com.rti.ndds.config.Logger.get_instance().set_output_device(slf4jDdsLogger);
  com.rti.ndds.config.Logger.get_instance().set_print_format(LogPrintFormat.NDDS_CONFIG_LOG_PRINT_FORMAT_TIMESTAMPED);

  // set log level
  if (LOGGER.isTraceEnabled()) {
    com.rti.ndds.config.Logger.get_instance().set_verbosity(LogVerbosity.NDDS_CONFIG_LOG_VERBOSITY_STATUS_ALL);
  } else if (LOGGER.isWarnEnabled()) {
    com.rti.ndds.config.Logger.get_instance().set_verbosity(LogVerbosity.NDDS_CONFIG_LOG_VERBOSITY_WARNING);
  } else if (LOGGER.isErrorEnabled()) {
    com.rti.ndds.config.Logger.get_instance().set_verbosity(LogVerbosity.NDDS_CONFIG_LOG_VERBOSITY_ERROR);
  }

  // return logger
  return slf4jDdsLogger;
}
 
開發者ID:aguther,項目名稱:dds-examples,代碼行數:21,代碼來源:Slf4jDdsLogger.java

示例12: close

import org.slf4j.Logger; //導入依賴的package包/類
public static void close(ThreadPoolExecutor executor, Logger logger) {
  executor.shutdown(); // Disable new tasks from being submitted
  try {
    // Wait a while for existing tasks to terminate
    if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
      executor.shutdownNow(); // Cancel currently executing tasks
      // Wait a while for tasks to respond to being cancelled
      if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
        logger.error("Pool did not terminate");
      }
    }
  } catch (InterruptedException ie) {
    logger.warn("Executor interrupted while awaiting termination");

    // (Re-)Cancel if current thread also interrupted
    executor.shutdownNow();
    // Preserve interrupt status
    Thread.currentThread().interrupt();
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:21,代碼來源:AutoCloseables.java

示例13: exParamDeal

import org.slf4j.Logger; //導入依賴的package包/類
private void exParamDeal(WObject wObject, PorterOfFun porterOfFun, ParamDealt.FailedReason reason,
        boolean responseWhenException)
{
    Logger LOGGER = logger(wObject);
    JResponse jResponse = null;
    if (LOGGER.isDebugEnabled() || responseWhenException)
    {
        jResponse = toJResponse(reason, wObject);
        LOGGER.debug("{}:{}", wObject.url(), jResponse);
    }
    if (responseWhenException)
    {
        if (jResponse == null)
        {
            jResponse = toJResponse(reason, wObject);
        }
        doFinalWrite(wObject, porterOfFun, jResponse);
    }
    close(wObject);
}
 
開發者ID:gzxishan,項目名稱:OftenPorter,代碼行數:21,代碼來源:PortExecutor.java

示例14: main

import org.slf4j.Logger; //導入依賴的package包/類
/**
 * The entry point of application.
 *
 * @param args the command line arguments
 */
public static void main(String[] args) {
    Logger logger = LoggerFactory.getLogger(GUILabelingTool.class);
    System.getProperty("java.library.path");

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(() -> {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            //  SplashScreen.startSplash()

            GUILabelingTool gui = new GUILabelingTool(logger);
            gui.setVisible(true);
            // for the first run, some special configuration have to be done
            gui.firstStartInitialization();

        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            logger.error("Create and display form");
            logger.debug("Create and display form {}", ex);
        }
    });
}
 
開發者ID:buni-rock,項目名稱:Pixie,代碼行數:27,代碼來源:GUILabelingTool.java

示例15: VirtualTool

import org.slf4j.Logger; //導入依賴的package包/類
@Inject
public VirtualTool(@ConfigDir(sharedRoot = true) Path path, Logger logger, PluginContainer container) {
    this.dataDir = Sponge.getGame().getSavesDirectory().resolve(PluginData.id);
    this.pluginContainer = container;
    this.logger = new VTLogger(CText.get(CText.Colors.BLUE, 1, "V") + CText.get(CText.Colors.MAGENTA, 0, "T"));
    this.configdirpath = path.resolve(PluginData.id);
    this.backpackDir = Paths.get(this.getConfigPath().toString(), "backpacks");
    this.configfullpath = Paths.get(this.getConfigPath().toString(), "config.json");
    this.settings = new Settings();
}
 
開發者ID:poqdavid,項目名稱:VirtualTool,代碼行數:11,代碼來源:VirtualTool.java


注:本文中的org.slf4j.Logger類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。