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


Java LogLog.error方法代碼示例

本文整理匯總了Java中org.apache.log4j.helpers.LogLog.error方法的典型用法代碼示例。如果您正苦於以下問題:Java LogLog.error方法的具體用法?Java LogLog.error怎麽用?Java LogLog.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.log4j.helpers.LogLog的用法示例。


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

示例1: subAppend

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
/**
 * This method differentiates OpenraspDailyRollingFileAppender from its
 * super class.
 *
 * <p>Before actually logging, this method will check whether it is
 * time to do a rollover. If it is, it will schedule the next
 * rollover time and then rollover.
 * */
protected void subAppend(LoggingEvent event) {
    long n = System.currentTimeMillis();
    if (n >= nextCheck) {
        now.setTime(n);
        nextCheck = rc.getNextCheckMillis(now);
        try {
            rollOver();
        }
        catch(IOException ioe) {
            if (ioe instanceof InterruptedIOException) {
                Thread.currentThread().interrupt();
            }
            LogLog.error("rollOver() failed.", ioe);
        }
    }
    super.subAppend(event);
}
 
開發者ID:baidu,項目名稱:openrasp,代碼行數:26,代碼來源:OpenraspDailyRollingFileAppender.java

示例2: activateOptions

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
public void activateOptions() {
    super.activateOptions();
    if(datePattern != null && fileName != null) {
        now.setTime(System.currentTimeMillis());
        sdf = new SimpleDateFormat(datePattern);
        int type = computeCheckPeriod();
        printPeriodicity(type);
        rc.setType(type);
        File file = new File(fileName);
        scheduledFilename = fileName+sdf.format(new Date(file.lastModified()));

    } else {
        LogLog.error("Either File or DatePattern options are not set for appender ["
                +name+"].");
    }
}
 
開發者ID:baidu,項目名稱:openrasp,代碼行數:17,代碼來源:OpenraspDailyRollingFileAppender.java

示例3: connect

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
void connect(InetAddress address, int port) {
   if(this.address == null)
     return;
   try {
     // First, close the previous connection if any.
     cleanUp();
     stw = new SyslogTcpWriter(new Socket(address, port).getOutputStream(), syslogFacility);
   } catch(IOException e) {
     if (e instanceof InterruptedIOException) {
         Thread.currentThread().interrupt();
     }
     String msg = "Could not connect to remote log4j server at ["
+address.getHostName()+"].";
     if(reconnectionDelay > 0) {
       msg += " We will try again later.";
fireConnector(); // fire the connector thread
     } else {
         msg += " We are not retrying.";
         errorHandler.error(msg, e, ErrorCode.GENERIC_FAILURE);
     } 
     LogLog.error(msg);
   }
 }
 
開發者ID:baidu,項目名稱:openrasp,代碼行數:24,代碼來源:SyslogTcpAppender.java

示例4: attemptToSend

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
private List<LogMessage> attemptToSend(List<LogMessage> batch)
{
    if (batch.isEmpty())
        return batch;

    PutLogEventsRequest request = new PutLogEventsRequest()
                                  .withLogGroupName(groupName)
                                  .withLogStreamName(streamName)
                                  .withLogEvents(constructLogEvents(batch));

    // sending is all-or-nothing with CloudWatch; we'll return the entire batch
    // if there's an exception

    try
    {
        LogStream stream = findLogStream();
        request.setSequenceToken(stream.getUploadSequenceToken());
        client.putLogEvents(request);
        return Collections.emptyList();
    }
    catch (Exception ex)
    {
        LogLog.error("failed to send batch", ex);
        return batch;
    }
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:27,代碼來源:CloudWatchLogWriter.java

示例5: stopWriter

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
/**
 *  Closes the current writer.
 */
private void stopWriter()
{
    synchronized (initializationLock)
    {
        try
        {
            if (writer == null)
                return;

            if (layout.getFooter() != null)
            {
                internalAppend(new LogMessage(System.currentTimeMillis(), layout.getFooter()));
            }

            writer.stop();
        }
        catch (Exception ex)
        {
            LogLog.error("exception while shutting down writer", ex);
        }
        writer = null;
    }
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:27,代碼來源:AbstractAppender.java

示例6: setBuffer

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
/**
 * Defines how many messages will be buffered until they will be updated to
 * the database.
 *
 * @param value
 *            The new Buffer value
 */
public void setBuffer(String value) {
	if (value == null) { return; }

	value = value.trim();

	if (value.length() == 0) { return; }

	try {
		buffer_size = Integer.parseInt(value);
	} catch (Exception e) {
		String errorMsg = "JDBCAppender::setBuffer(), Invalid BUFFER_OPTION value : " + value
				+ " !";
		LogLog.error(errorMsg);
		errorHandler.error(errorMsg, null, 0);
		return;
	}
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:25,代碼來源:JDBCAppender.java

示例7: processBatch

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
@Override
protected List<LogMessage> processBatch(List<LogMessage> currentBatch)
{
    // although we should only ever get a single message we'll process as a list
    List<LogMessage> failures = new ArrayList<LogMessage>();
    for (LogMessage message : currentBatch)
    {
        try
        {
            PublishRequest request = new PublishRequest()
                                     .withTopicArn(topicArn)
                                     .withMessage(message.getMessage());
            if (config.subject != null)
            {
                request.setSubject(config.subject);
            }
            client.publish(request);
        }
        catch (Exception ex)
        {
            LogLog.error("failed to send message", ex);
            failures.add(message);
        }
    }
    return failures;
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:27,代碼來源:SNSLogWriter.java

示例8: activateOptions

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
/**
 * Activate the options set using <tt>setHosts()</tt>, <tt>setSelector</tt>
 * and <tt>setMaxBackoff</tt>
 *
 * @throws FlumeException
 *           if the LoadBalancingRpcClient cannot be instantiated.
 */
@Override
public void activateOptions() throws FlumeException {
  try {
    final Properties properties = getProperties(hosts, selector, maxBackoff, getTimeout());
    rpcClient = RpcClientFactory.getInstance(properties);
    if (layout != null) {
      layout.activateOptions();
    }
    configured = true;
  } catch (Exception e) {
    String errormsg = "RPC client creation failed! " + e.getMessage();
    LogLog.error(errormsg);
    if (getUnsafeMode()) {
      return;
    }
    throw new FlumeException(e);
  }

}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:27,代碼來源:LoadBalancingLog4jAppender.java

示例9: close

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
/**
 * Closes underlying client.
 * If <tt>append()</tt> is called after this function is called,
 * it will throw an exception.
 * @throws FlumeException if errors occur during close
 */
@Override
public synchronized void close() throws FlumeException {
  // Any append calls after this will result in an Exception.
  if (rpcClient != null) {
    try {
      rpcClient.close();
    } catch (FlumeException ex) {
      LogLog.error("Error while trying to close RpcClient.", ex);
      if (unsafeMode) {
        return;
      }
      throw ex;
    } finally {
      rpcClient = null;
    }
  } else {
    String errorMsg = "Flume log4jappender already closed!";
    LogLog.error(errorMsg);
    if (unsafeMode) {
      return;
    }
    throw new FlumeException(errorMsg);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:31,代碼來源:Log4jAppender.java

示例10: activateOptions

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
/**
 * Activate the options set using <tt>setPort()</tt>
 * and <tt>setHostname()</tt>
 *
 * @throws FlumeException if the <tt>hostname</tt> and
 *                        <tt>port</tt> combination is invalid.
 */
@Override
public void activateOptions() throws FlumeException {
  Properties props = new Properties();
  props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1");
  props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1",
      hostname + ":" + port);
  props.setProperty(RpcClientConfigurationConstants.CONFIG_CONNECT_TIMEOUT,
      String.valueOf(timeout));
  props.setProperty(RpcClientConfigurationConstants.CONFIG_REQUEST_TIMEOUT,
      String.valueOf(timeout));
  try {
    rpcClient = RpcClientFactory.getInstance(props);
    if (layout != null) {
      layout.activateOptions();
    }
  } catch (FlumeException e) {
    String errormsg = "RPC client creation failed! " + e.getMessage();
    LogLog.error(errormsg);
    if (unsafeMode) {
      return;
    }
    throw e;
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:32,代碼來源:Log4jAppender.java

示例11: configure

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
/** Overwrites the jlogger field on the base class with a JDBCLoggerWithAttachment instance if:
 * <ul>
 * <li> Attachment settings are provided in the configuration file
 * <li> The usePreparedStatements should be true
 * <li> The stored-procedure, sql and sqlHandler should not be specified.
 * </ul>
 * Finally it invokes the configure() method in the base class.
 * @return true if the configuration was successful.
 */
protected boolean configure() {
    try {
        if (!((Boolean) c_configured.get(this)).booleanValue()) {
            // Customize the logger if attachmentTable and attachmentMDCKey are provided and if using prepared statements.
            // Ensure that stored-procedure, sql or sqlHandler are not being used.
            if (getAttachmentTable() != null && getAttachmentMDCKey() != null && isUsePreparedStatements()
            && getProcedure() == null && getSql() == null) {
                // Use reflection to check the 'sqlHandler' field from the base class, since there is no getter
                if (c_sqlHandler.get(this) == null) {
                    // Use reflection to set the 'jlogger' field on the base class, since there is no setter
                    c_jlogger.set(this, new JDBCLoggerWithAttachment(getAttachmentTable(), getAttachmentMDCKey(), getEngine()));
                    LogLog.debug("JDBCAppenderWithAttachment::configure(), Using JDBCLoggerWithAttachment");
                }
                
            }
            return super.configure();
        } else
            return true;
    } catch (Exception e) {
        String errorMsg = "JDBCAppenderWithAttachment::configure()";
        LogLog.error(errorMsg, e);
        errorHandler.error(errorMsg, e, 0);
        return false;
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:35,代碼來源:JDBCAppenderWithAttachment.java

示例12: activateOptions

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
public void activateOptions()
{
	super.activateOptions();
	if (datePattern != null && fileName != null)
	{
		now.setTime(System.currentTimeMillis());
		sdf = new SimpleDateFormat(datePattern);
		int type = computeCheckPeriod();
		printPeriodicity(type);
		rc.setType(type);
		File file = new File(fileName);
		scheduledFilename = fileName + sdf.format(new Date(file.lastModified()));
		
	}
	else
	{
		LogLog.error("Either File or DatePattern options are not set for appender [" + name + "].");
	}
}
 
開發者ID:varra4u,項目名稱:utils4j,代碼行數:20,代碼來源:BackupEnabledDailyRollingFileAppender.java

示例13: subAppend

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
/**
 * This method differentiates DailyRollingFileAppender from its super class.
 * 
 * <p>
 * Before actually logging, this method will check whether it is time to do
 * a rollover. If it is, it will schedule the next rollover time and then
 * rollover.
 * 
 * @param event
 *            the event
 */
protected void subAppend(LoggingEvent event)
{
	long n = System.currentTimeMillis();
	if (n >= nextCheck)
	{
		now.setTime(n);
		nextCheck = rc.getNextCheckMillis(now);
		try
		{
			rollOver();
		}
		catch (IOException ioe)
		{
			if (ioe instanceof InterruptedIOException)
			{
				Thread.currentThread().interrupt();
			}
			LogLog.error("rollOver() failed.", ioe);
		}
	}
	super.subAppend(event);
}
 
開發者ID:varra4u,項目名稱:utils4j,代碼行數:34,代碼來源:BackupEnabledDailyRollingFileAppender.java

示例14: close

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
/**
 * When system exit,this method will be called to close resources
 */
public synchronized void close() {
    // The synchronized modifier avoids concurrent append and close operations

    if (this.closed)
        return;

    LogLog.debug("Closing RocketmqLog4jAppender [" + name + "].");
    this.closed = true;

    try {
        ProducerInstance.getProducerInstance().removeAndClose(this.nameServerAddress, this.producerGroup);
    } catch (Exception e) {
        LogLog.error("Closing RocketmqLog4jAppender [" + name + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
    }
    // Help garbage collection
    producer = null;
}
 
開發者ID:apache,項目名稱:rocketmq,代碼行數:21,代碼來源:RocketmqLog4jAppender.java

示例15: close

import org.apache.log4j.helpers.LogLog; //導入方法依賴的package包/類
/**
 * 關閉appender,即關閉其中所有的writer
 */
@Override
public synchronized void close() {
	if (this.closed)
		return;
	this.closed = true;
	for (Map.Entry<String, CountingQuietWriterEx> en : writers.entrySet()) {
		try {
			en.getValue().close();
		} catch (IOException e) {
			LogLog.error("關閉日誌文件Writer失敗:" + en.getKey(), e);
		}
	}
	writers.clear();
	executor.shutdown();
}
 
開發者ID:dreajay,項目名稱:jcode,代碼行數:19,代碼來源:GroupRollingFileAppender.java


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