• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ErrorCode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.log4j.spi.ErrorCode的典型用法代码示例。如果您正苦于以下问题:Java ErrorCode类的具体用法?Java ErrorCode怎么用?Java ErrorCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ErrorCode类属于org.apache.log4j.spi包,在下文中一共展示了ErrorCode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: connect

import org.apache.log4j.spi.ErrorCode; //导入依赖的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


示例2: append

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
@Override
protected void append(LoggingEvent event) {
    if (this.layout == null) {
        errorHandler.error("No layout for appender " + name,
                null, ErrorCode.MISSING_LAYOUT);
        return;
    }
    String message = this.layout.format(event);
    Session session = sessions.get(event.getThreadName());
    if (session != null) {
        try {
            session.getBasicRemote().sendText(gson.toJson(new Response(message, "", false)));
        } catch (IOException ex) {
            System.err.println("IOException " + ex.getMessage());
        }
    } else {
        System.err.println("No session found for thread " + event.getThreadName());
    }
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:20,代码来源:StringWriterAppender.java


示例3: append

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
    This method called by {@link AppenderSkeleton#doAppend} method to
    do most of the real appending work.  */
 public void append(LoggingEvent event) {
   if(!checkEntryConditions()) {
     return;
   }

   try {
     ObjectMessage msg = topicSession.createObjectMessage();
     if(locationInfo) {
event.getLocationInformation();
     }
     msg.setObject(event);
     topicPublisher.publish(msg);
   } catch(Exception e) {
     errorHandler.error("Could not publish message in JMSAppender ["+name+"].", e,
		 ErrorCode.GENERIC_FAILURE);
   }
 }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:21,代码来源:JMSAppender.java


示例4: connect

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
void connect(InetAddress address, int port) {
   if(this.address == null)
     return;
   try {
     // First, close the previous connection if any.
     cleanUp();
     oos = new ObjectOutputStream(new Socket(address, port).getOutputStream());
   } catch(IOException e) {

     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:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:SocketAppender.java


示例5: activateOptions

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
    If the value of <b>File</b> is not <code>null</code>, then {@link
    #setFile} is called with the values of <b>File</b>  and
    <b>Append</b> properties.

    @since 0.8.1 */
 public
 void activateOptions() {
   if(fileName != null) {
     try {
setFile(fileName, fileAppend, bufferedIO, bufferSize);
     }
     catch(java.io.IOException e) {
errorHandler.error("setFile("+fileName+","+fileAppend+") call failed.",
		   e, ErrorCode.FILE_OPEN_FAILURE);
     }
   } else {
     //LogLog.error("File option not set for appender ["+name+"].");
     LogLog.warn("File option not set for appender ["+name+"].");
     LogLog.warn("Are you using FileAppender instead of ConsoleAppender?");
   }
 }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:FileAppender.java


示例6: activateOptions

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
    * Overriding this method to activate the options for this class
    * i.e. Looking up the Connection factory ...
    */
   public void activateOptions() {

QueueConnectionFactory queueConnectionFactory;

try {

    Context ctx = getInitialContext();      
    queueConnectionFactory = (QueueConnectionFactory) ctx.lookup(queueConnectionFactoryBindingName);
    queueConnection = queueConnectionFactory.createQueueConnection();
   
    queueSession = queueConnection.createQueueSession(false,
						      Session.AUTO_ACKNOWLEDGE);
     
    Queue queue = (Queue) ctx.lookup(queueBindingName);
    queueSender = queueSession.createSender(queue);
    
    queueConnection.start();

    ctx.close();      

} catch(Exception e) {
    errorHandler.error("Error while activating options for appender named ["+name+
		       "].", e, ErrorCode.GENERIC_FAILURE);
}
   }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:30,代码来源:JMSQueueAppender.java


示例7: append

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
    * This method called by {@link AppenderSkeleton#doAppend} method to
    * do most of the real appending work.  The LoggingEvent will be
    * be wrapped in an ObjectMessage to be put on the JMS queue.
    */
   public void append(LoggingEvent event) {

if(!checkEntryConditions()) {
    return;
}

try {

    ObjectMessage msg = queueSession.createObjectMessage();
    msg.setObject(event);
    queueSender.send(msg);

} catch(Exception e) {
    errorHandler.error("Could not send message in JMSQueueAppender ["+name+"].", e, 
		       ErrorCode.GENERIC_FAILURE);
}
   }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:JMSQueueAppender.java


示例8: parseAddress

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
InternetAddress[] parseAddress(String addressStr) {
    try {
        InternetAddress[] as = InternetAddress.parse(addressStr, true);
        if (as != null && as.length > 0) {
            for (InternetAddress a : as) {
                a.setPersonal(a.getPersonal());
            }
        }
        return as;
    }catch (UnsupportedEncodingException e1){
        errorHandler.error("Could not parse address ["+addressStr+"].", e1,
                ErrorCode.ADDRESS_PARSE_FAILURE);
    } catch(AddressException e) {
        errorHandler.error("Could not parse address ["+addressStr+"].", e,
                ErrorCode.ADDRESS_PARSE_FAILURE);
    }
    return null;
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:19,代码来源:EmailDailyRollingFileAppender.java


示例9: flushBuffer

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
 * loops through the buffer of LoggingEvents, gets a
 * sql string from getLogStatement() and sends it to execute().
 * Errors are sent to the errorHandler.
 *
 * If a statement fails the LoggingEvent stays in the buffer!
 */
public void flushBuffer() {
  //Do the actual logging
  removes.ensureCapacity(buffer.size());
  for (Iterator i = buffer.iterator(); i.hasNext();) {
    LoggingEvent logEvent = (LoggingEvent)i.next();
    try {
   String sql = getLogStatement(logEvent);
   execute(sql);
    }
    catch (SQLException e) {
   errorHandler.error("Failed to excute sql", e,
	   ErrorCode.FLUSH_FAILURE);
    } finally {
      removes.add(logEvent);
    }
  }
  
  // remove from the buffer any events that were reported
  buffer.removeAll(removes);
  
  // clear the buffer of reported events
  removes.clear();
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:31,代码来源:JDBCAppender.java


示例10: connect

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
void connect(InetAddress address, int port) {
   if(this.address == null)
     return;
   try {
     // First, close the previous connection if any.
     cleanUp();
     oos = new ObjectOutputStream(new Socket(address, port).getOutputStream());
   } 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:DiamondLightSource,项目名称:daq-eclipse,代码行数:24,代码来源:SocketAppender.java


示例11: activateOptions

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
 * @see org.apache.log4j.AppenderSkeleton#activateOptions()
 */
@Override
public void activateOptions() {
    try {
        // Close previous connections if reactivating
        if (mongo != null) {
            close();
        }

        initialize();

    } catch (final Exception e) {
        errorHandler.error("Unexpected exception while initialising MongoDbAppender.", e,
                ErrorCode.GENERIC_FAILURE);
    }
}
 
开发者ID:d0k1,项目名称:log4jmongo,代码行数:19,代码来源:SimpleMongoDbAppender.java


示例12: getPortNums

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
private List<Integer> getPortNums(final String[] ports) {
    final List<Integer> portNums = new ArrayList<Integer>();

    for (final String port : ports) {
        try {
            final Integer portNum = Integer.valueOf(port.trim());
            if (portNum < 0) {
                errorHandler.error(
                        "MongoDB appender port property can't contain a negative integer",
                        null, ErrorCode.ADDRESS_PARSE_FAILURE);
            } else {
                portNums.add(portNum);
            }
        } catch (final NumberFormatException e) {
            errorHandler.error(
                    "MongoDB appender can't parse a port property value into an integer", e,
                    ErrorCode.ADDRESS_PARSE_FAILURE);
        }

    }

    return portNums;
}
 
开发者ID:d0k1,项目名称:log4jmongo,代码行数:24,代码来源:SimpleMongoDbAppender.java


示例13: saveQueue

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
 * Method that creates query for OrientDB from the JSONObject event in the queue
 * and executes it in the database
 * @see {@link DataBaseAppender}{@link #saveQueue()} 
 */
@Override
protected void saveQueue() {
	// TODO Auto-generated method stub
	if (queue.size() == 0)
		return;
	StringBuffer cmd = new StringBuffer("begin\n");
	for (Object obj : queue) {
		cmd.append("insert into " + table + " content " + ((JSONObject) obj).toString() + "\n");
	}
	cmd.append("commit\n");
	//System.out.println(cmd);
	try
	{
		database.command(new OCommandScript("sql", cmd.toString())).execute();
	}
	catch(Exception e){
		errorHandler.error("Unexpected exception while saving events", e,
				ErrorCode.GENERIC_FAILURE);
	}
}
 
开发者ID:zahidMed,项目名称:log4j-database,代码行数:26,代码来源:OrientDBAppender.java


示例14: append

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
 * To a log event to the logger.
 * 
 * @param event
 *            LoggingEvent.
 */
@Override
public void append( LoggingEvent event )
{
    try
    {
        dirName = ( String ) event.getMDC( "SettopMac" );
        fileName = ( String ) event.getMDC( "LogFileName" );
        String logFileName = System.getProperty( "cats.home" ) + File.separator + dirName + File.separator
                + fileName;
        setFile( logFileName, fileAppend, bufferedIO, bufferSize );
        MDC.remove( "SettopMac" );
        MDC.remove( "LogFileName" );
    }
    catch ( IOException ie )
    {
        errorHandler.error( "Error occured while setting file for the log level " + event.getLevel(), ie,
                ErrorCode.FILE_OPEN_FAILURE );
    }
    super.append( event );
}
 
开发者ID:Comcast,项目名称:cats,代码行数:27,代码来源:SettopLoggerFileAppender.java


示例15: close

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
 * Closes this appender instance. Before exiting, the implementation tries to
 * flush out buffered log events within configured shutdownTimeout seconds. If
 * that doesn't finish within configured shutdownTimeout, it would drop all
 * the buffered log events.
 */
@Override
public void close() {
  ThreadPoolExecutor threadpool = (ThreadPoolExecutor) kinesisClient.getExecutorService();
  threadpool.shutdown();
  BlockingQueue<Runnable> taskQueue = threadpool.getQueue();
  int bufferSizeBeforeShutdown = threadpool.getQueue().size();
  boolean gracefulShutdown = true;
  try {
    gracefulShutdown = threadpool.awaitTermination(shutdownTimeout, TimeUnit.SECONDS);
  } catch (InterruptedException e) {
    // we are anyways cleaning up
  } finally {
    int bufferSizeAfterShutdown = taskQueue.size();
    if (!gracefulShutdown || bufferSizeAfterShutdown > 0) {
      String errorMsg = "Kinesis Log4J Appender (" + name + ") waited for " + shutdownTimeout
          + " seconds before terminating but could send only " + (bufferSizeAfterShutdown - bufferSizeBeforeShutdown)
          + " logevents, it failed to send " + bufferSizeAfterShutdown
          + " pending log events from it's processing queue";
      LOGGER.error(errorMsg);
      errorHandler.error(errorMsg, null, ErrorCode.WRITE_FAILURE);
    }
  }
  kinesisClient.shutdown();
}
 
开发者ID:awslabs,项目名称:kinesis-log4j-appender,代码行数:31,代码来源:KinesisAppender.java


示例16: append

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
 * This method is called whenever a logging happens via logger.log(..) API
 * calls. Implementation for this appender will take in log events instantly
 * as long as the buffer is not full (as per user configuration). This call
 * will block if internal buffer is full until internal threads create some
 * space by publishing some of the records.
 * 
 * If there is any error in parsing logevents, those logevents would be
 * dropped.
 */
@Override
public void append(LoggingEvent logEvent) {
  if (initializationFailed) {
    error("Check the configuration and whether the configured stream " + streamName
        + " exists and is active. Failed to initialize kinesis log4j appender: " + name);
    return;
  }
  try {
    String message = layout.format(logEvent);
    ByteBuffer data = ByteBuffer.wrap(message.getBytes(encoding));
    kinesisClient.putRecordAsync(new PutRecordRequest().withPartitionKey(UUID.randomUUID().toString())
        .withStreamName(streamName).withData(data), asyncCallHander);
  } catch (Exception e) {
    LOGGER.error("Failed to schedule log entry for publishing into Kinesis stream: " + streamName);
    errorHandler.error("Failed to schedule log entry for publishing into Kinesis stream: " + streamName, e,
        ErrorCode.WRITE_FAILURE, logEvent);
  }
}
 
开发者ID:awslabs,项目名称:kinesis-log4j-appender,代码行数:29,代码来源:KinesisAppender.java


示例17: activateOptions

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
/**
 * Called when a new log attempt is made, either due to server restart or rollover. The filename
 * is modified to identify the logging node in getNewFileName.
 */
@Override
public void activateOptions() {
  if (fileName != null) {
    if (!fileName.equals(mCurrentFileName)) {
      mOriginalFileName = fileName;
    } else {
      fileName = mOriginalFileName;
    }
    try {
      fileName = getNewLogFileName(fileName);
      setFile(fileName, fileAppend, bufferedIO, bufferSize);
    } catch (Exception e) {
      errorHandler.error("Error while activating log options", e, ErrorCode.FILE_OPEN_FAILURE);
    }
  }
}
 
开发者ID:mtunique,项目名称:tachyon-rdma,代码行数:21,代码来源:Log4jFileAppender.java


示例18: write

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
public final void write(final String string) {
  if (string == null) {
    /*
     * Create an exception here so that a stack trace is available for
     * debugging purposes.
     */
    errorHandler.error("Attempt to write null - see Log4J bug list.",
        new RuntimeException("Fault in Log4J Layout"),
        ErrorCode.WRITE_FAILURE);
    return;
  }
  try {
    synchronized (lock) {
      final int length = string.length();
      out.write(string, 0, length);
      this.charCount += length;
    }
  } catch (IOException e) {
    if (e instanceof InterruptedIOException) {
      Thread.currentThread().interrupt();
    }
    errorHandler.error("Failed to write [" + string + "].", e,
        ErrorCode.WRITE_FAILURE);
  }
}
 
开发者ID:foundation-runtime,项目名称:logging,代码行数:26,代码来源:SynchronizedCountingQuietWriter.java


示例19: activateOptions

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
public void activateOptions() {
if (fileName != null) {
    try {
    	Date dNow = new Date( );
        SimpleDateFormat ft = new SimpleDateFormat ("yyyy_MM_dd_hh_mm_ss");
        
		String dirName = "Log_" + ft.format(dNow);
		File dir = new File("log/" + dirName);
		dir.mkdir();

		fileName = dir.getPath() + "/calculated_values.log";
        setFile(fileName, fileAppend, bufferedIO, bufferSize);
    } catch (Exception e) {
        errorHandler.error("Error while activating log options", e,
                ErrorCode.FILE_OPEN_FAILURE);
    }
}
}
 
开发者ID:EclipseETS,项目名称:eclipse-telemetry,代码行数:19,代码来源:AppenderCalculatedValues.java


示例20: activateOptions

import org.apache.log4j.spi.ErrorCode; //导入依赖的package包/类
public void activateOptions() {
if (fileName != null) {
    try {
    	Date dNow = new Date( );
        SimpleDateFormat ft = new SimpleDateFormat ("yyyy_MM_dd_hh_mm_ss");
        
		String dirName = "Log_" + ft.format(dNow);
		File dir = new File("log/" + dirName);
		dir.mkdir();

    	fileName = dir.getPath() + "/telemetry.log";
        setFile(fileName, fileAppend, bufferedIO, bufferSize);
    } catch (Exception e) {
        errorHandler.error("Error while activating log options", e,
                ErrorCode.FILE_OPEN_FAILURE);
    }
}
}
 
开发者ID:EclipseETS,项目名称:eclipse-telemetry,代码行数:19,代码来源:AppenderTelemetry.java



注:本文中的org.apache.log4j.spi.ErrorCode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IdleConnectionTimeoutThread类代码示例发布时间:2022-05-21
下一篇:
Java CloudSolrServer类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap