当前位置: 首页>>代码示例>>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;未经允许,请勿转载。