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


Java LogLog類代碼示例

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


LogLog類屬於org.apache.log4j.helpers包,在下文中一共展示了LogLog類的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: cleanUp

import org.apache.log4j.helpers.LogLog; //導入依賴的package包/類
/**
  * Drop the connection to the remote host and release the underlying
  * connector thread if it has been created 
  * */
 public void cleanUp() {
   if(stw != null) {
     try {
stw.close();
     } catch(IOException e) {
         if (e instanceof InterruptedIOException) {
             Thread.currentThread().interrupt();
         }
      LogLog.error("Could not close stw.", e);
     }
     stw = null;
   }
   if(connector != null) {
     //LogLog.debug("Interrupting the connector.");
     connector.interrupted = true;
     connector = null;  // allow gc
   }
 }
 
開發者ID:baidu,項目名稱:openrasp,代碼行數:23,代碼來源:SyslogTcpAppender.java

示例4: 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

示例5: 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.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:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:21,代碼來源:RocketmqLog4jAppender.java

示例6: 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

示例7: append

import org.apache.log4j.helpers.LogLog; //導入依賴的package包/類
@Override
protected void append(LoggingEvent event)
{
    if (closed)
    {
        throw new IllegalStateException("appender is closed");
    }

    if (! ready)
    {
        initialize();
    }

    try
    {
        internalAppend(new LogMessage(event, getLayout()));
    }
    catch (Exception ex)
    {
        LogLog.warn("unable to append event", ex);
    }
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:23,代碼來源:AbstractAppender.java

示例8: 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

示例9: internalAppend

import org.apache.log4j.helpers.LogLog; //導入依賴的package包/類
private void internalAppend(LogMessage message)
{
    if (message == null)
        return;

    if (isMessageTooLarge(message))
    {
        LogLog.warn("attempted to append a message > AWS batch size; ignored");
        return;
    }

    rotateIfNeeded(System.currentTimeMillis());

    synchronized (messageQueueLock)
    {
        if (writer == null)
        {
            LogLog.warn("appender not properly configured: writer is null");
        }
        else
        {
            writer.addMessage(message);
            lastRotationCount++;
        }
    }
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:27,代碼來源:AbstractAppender.java

示例10: tryClientFactory

import org.apache.log4j.helpers.LogLog; //導入依賴的package包/類
/**
 *  Attempts to use a factory method to create the service client.
 *
 *  @param  clientFactoryName   Fully qualified name of a static factory method.
 *                              If empty or null, this function returns null (used
 *                              to handle optionally-configured factories).
 *  @param  expectedClientClass The interface fullfilled by this client.
 *  @param  rethrow             If true, any reflection exceptions will be wrapped
 *                              and rethrown; if false, exceptions return null
 */
protected <T> T tryClientFactory(String clientFactoryName, Class<T> expectedClientClass, boolean rethrow)
{
    if ((clientFactoryName == null) || clientFactoryName.isEmpty())
        return null;

    try
    {
        int methodIdx = clientFactoryName.lastIndexOf('.');
        if (methodIdx < 0)
            throw new RuntimeException("invalid AWS client factory specified: " + clientFactoryName);
        Class<?> factoryKlass = Class.forName(clientFactoryName.substring(0, methodIdx));
        Method factoryMethod = factoryKlass.getDeclaredMethod(clientFactoryName.substring(methodIdx + 1));
        T client = expectedClientClass.cast(factoryMethod.invoke(null));
        factoryMethodUsed = clientFactoryName;
        LogLog.debug(getClass().getSimpleName() + ": created client from factory: " + clientFactoryName);
        return client;
    }
    catch (Exception ex)
    {
        if (rethrow)
            throw new RuntimeException("unable to invoke AWS client factory", ex);
        else
            return null;
    }
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:36,代碼來源:AbstractLogWriter.java

示例11: tryConfigureEndpointOrRegion

import org.apache.log4j.helpers.LogLog; //導入依賴的package包/類
/**
 *  Common support code: attempts to configure client endpoint and/or region.
 *
 *  @param  client      A constructed writer-specific service client.
 *  @param  endpoint    A possibly-null endpoint specification.
 */
protected <T extends AmazonWebServiceClient> T tryConfigureEndpointOrRegion(T client, String endpoint)
{
    // explicit endpoint takes precedence over region retrieved from environment
    if (endpoint != null)
    {
        LogLog.debug(getClass().getSimpleName() + ": configuring endpoint: " + endpoint);
        client.setEndpoint(endpoint);
        return client;
    }

    String region = System.getenv("AWS_REGION");
    if (region != null)
    {
        LogLog.debug(getClass().getSimpleName() + ": configuring region: " + region);
        client.configureRegion(Regions.fromName(region));
        return client;
    }

    return client;
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:27,代碼來源:AbstractLogWriter.java

示例12: retrieveAWSAccountId

import org.apache.log4j.helpers.LogLog; //導入依賴的package包/類
/**
 *  Retrieves the current AWS account ID, using reflection so that we don't
 *  have a hard reference to the STS SDK JAR (ie, if you don't want account
 *  IDs you don't need the JAR).
 *  <p>
 *  Returns null if unable to determine the account ID for any reason.
 */
public static String retrieveAWSAccountId()
{
    try
    {
        Class<?> stsClientKlass = Class.forName("com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient");
        Class<?> requestKlass = Class.forName("com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest");
        Class<?> responseKlass = Class.forName("com.amazonaws.services.securitytoken.model.GetCallerIdentityResult");
        Object stsClient = stsClientKlass.newInstance();
        Object request = requestKlass.newInstance();
        Method requestMethod = stsClientKlass.getMethod("getCallerIdentity", requestKlass);
        Object response = requestMethod.invoke(stsClient, request);
        Method getAccountMethod = responseKlass.getMethod("getAccount");
        return (String)getAccountMethod.invoke(response);
    }
    catch (Exception ex)
    {
        LogLog.warn("substitutions: unable to retrieve AWS account ID");
        return null;
    }
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:28,代碼來源:Utils.java

示例13: 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

示例14: configureByName

import org.apache.log4j.helpers.LogLog; //導入依賴的package包/類
/**
 *  Attempts to find the configured topicName in the list of topics for
 *  the current account. If successful, configures the writer and returns
 *  true. If unsucessful, attempts to create the topic and configure as
 *  above.
 */
private boolean configureByName()
{
    if (! Pattern.matches(SNSConstants.TOPIC_NAME_REGEX, config.topicName))
    {
        return initializationFailure("invalid topic name: " + config.topicName, null);
    }

    topicArn = retrieveAllTopicsByName().get(config.topicName);
    if (topicArn != null)
    {
        return true;
    }
    else
    {
        LogLog.debug("creating SNS topic: " + config.topicName);
        CreateTopicResult response = client.createTopic(config.topicName);
        topicArn = response.getTopicArn();
        return true;
    }
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:27,代碼來源:SNSLogWriter.java

示例15: 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


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