本文整理匯總了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);
}
示例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+"].");
}
}
示例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
}
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
示例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++;
}
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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);
}
}