本文整理汇总了Java中org.apache.log4j.helpers.CountingQuietWriter类的典型用法代码示例。如果您正苦于以下问题:Java CountingQuietWriter类的具体用法?Java CountingQuietWriter怎么用?Java CountingQuietWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CountingQuietWriter类属于org.apache.log4j.helpers包,在下文中一共展示了CountingQuietWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subAppend
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
@Override
protected void subAppend(LoggingEvent event)
{
LogLog.debug("subAppend");
long now = System.currentTimeMillis();
if( now >= nextRollTime )
{
LogLog.debug("Have to roll directory");
calculateRollOverTime();
rollDirectory();
}
else if( getFile() != null && ((CountingQuietWriter) qw).getCount() >= maxFileSize )
{
LogLog.debug("Have to roll file");
rollFile();
}
LogLog.debug("Calling Super Sub Append");
super.subAppend(event);
}
示例2: subAppend
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
/**
* Handles append time behavior for CompositeRollingAppender. This checks
* if a roll over either by date (checked first) or time (checked second)
* is need and then appends to the file last.
*/
protected void subAppend(LoggingEvent event) {
if (rollDate) {
long n = System.currentTimeMillis();
if (n >= nextCheck) {
now.setTime(n);
nextCheck = rc.getNextCheckMillis(now);
rollOverTime();
}
}
if (rollSize) {
if ((fileName != null) && ((CountingQuietWriter) qw).getCount() >= maxFileSize) {
rollOverSize();
}
}
super.subAppend(event);
}
示例3: subAppend
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
/**
* This method differentiates RollingFileAppender from its super class.
*
* @since 0.9.0
*/
protected void subAppend(LoggingEvent event) {
super.subAppend(event);
if (fileName != null && qw != null) {
String nowDate = sdf.format(new Date());
// 检测日期是否已经变更了,如果变更了就要重创建日期目录
if (!fileMaps.get(fileName).getDate().equals(nowDate)) {
rollOver();
return;
}
long size = ((CountingQuietWriter) qw).getCount();
if (size >= maxFileSize && size >= nextRollover) {
rollOver();
}
}
}
示例4: subAppend
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
/**
* Handles append time behavior for CompositeRollingAppender. This checks if a roll over either by date (checked
* first) or time (checked second) is need and then appends to the file last.
*/
protected void subAppend(LoggingEvent event)
{
if (rollDate)
{
long n = System.currentTimeMillis();
if (n >= nextCheck)
{
now.setTime(n);
nextCheck = rc.getNextCheckMillis(now);
rollOverTime();
}
}
if (rollSize)
{
if ((fileName != null) && (((CountingQuietWriter) qw).getCount() >= maxFileSize))
{
rollOverSize();
}
}
super.subAppend(event);
}
示例5: setFile
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
/**
* Creates and opens the file for logging. If <code>staticLogFileName</code> is false then the fully qualified name
* is determined and used.
*/
public synchronized void setFile(String fileName, boolean append) throws IOException
{
if (!staticLogFileName)
{
scheduledFilename = fileName = fileName.trim() + sdf.format(now);
}
super.setFile(fileName, append, bufferedIO, bufferSize);
if (append)
{
File f = new File(fileName);
((CountingQuietWriter) qw).setCount(f.length());
}
}
示例6: rollOver
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
/**
* Implements the usual roll over behaviour.
* <p>
* <code>File</code> is renamed <code>File.yyyyMMddHHmmss</code> and closed. A
* new <code>File</code> is created to receive further log output.
*/
// synchronization not necessary since doAppend is alreasy synched
public void rollOver() {
if (qw != null) {
long size = ((CountingQuietWriter) qw).getCount();
LogLog.debug("rolling over count=" + size);
// if operation fails, do not roll again until
// maxFileSize more bytes are written
nextRollover = size + maxFileSize;
}
this.closeFile(); // keep windows happy.
String newFileName = getLogFileName(fileName);
try {
// This will also close the file. This is OK since multiple
// close operations are safe.
this.setFile(newFileName, false, bufferedIO, bufferSize);
nextRollover = 0;
} catch (IOException e) {
if (e instanceof InterruptedIOException) {
Thread.currentThread().interrupt();
}
LogLog.error("setFile(" + newFileName + ", false) call failed.", e);
}
}
示例7: subAppend
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
/**
This method differentiates RollingFileAppender from its super
class.
@since 0.9.0
*/
@Override
protected void subAppend(
LoggingEvent event ) {
super.subAppend(event);
if (fileName != null && qw != null) {
long size = ((CountingQuietWriter) qw).getCount();
if (size >= maxFileSize && size >= nextRollover) {
rollOver();
}
}
}
示例8: setFile
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
@Override
public synchronized void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize)
throws IOException
{
super.setFile(fileName, append, this.bufferedIO, this.bufferSize);
if( append )
{
File f = new File(fileName);
((CountingQuietWriter) qw).setCount(f.length());
}
}
示例9: subAppend
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
protected void subAppend(LoggingEvent event) {
if (event.getLevel().toInt() <= currentLevel) {
super.subAppend(event);
if (fileName != null && qw != null) {
long size = ((CountingQuietWriter) qw).getCount();
if (size >= maxFileSize && size >= nextRollover) {
rollOver();
}
}
}
}
示例10: subAppend
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
@SuppressWarnings("resource")
protected void subAppend(CountingQuietWriterEx qw, LoggingEvent event)
throws IOException {
// 此句不加可以节省20%的资源,但程序退出时日志会缺少
if (!bufferedIO)
qw.flush();
// 超过大小备份日志文件,并创建新文件
if (qw != null) {
long size = ((CountingQuietWriter) qw).getCount();
if (size >= maxFileSize) {// 超过单个日志大小
final String fileName = qw.getFileName();
String idx = fileName.substring(fileName.lastIndexOf(".") + 1);
qw = rollOver(qw, Integer.parseInt(idx) + 1);
} else {
String logDate = qw.getLogDate();
String today = format.format(new Date(event.timeStamp));
if (!logDate.equals("") && !logDate.equals(today)) {// 日切情况
qw = rollOver(qw, 0);
}
}
}
// 写日志,一定要调用write(string)方法,因为只有它才会累加count
qw.write(this.layout.format(event));
if (layout.ignoresThrowable()) {
// layout中忽略异常的处理,由此处写异常信息
String[] s = event.getThrowableStrRep();
if (s != null) {
int len = s.length;
for (int i = 0; i < len; i++) {
qw.write(s[i]);
qw.write(Layout.LINE_SEP);
}
}
}
}
示例11: setFile
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
public
synchronized
void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize)
throws IOException {
super.setFile(fileName, append, this.bufferedIO, this.bufferSize);
if(append) {
File f = new File(fileName);
((CountingQuietWriter) qw).setCount(f.length());
}
}
示例12: subAppend
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
/**
This method differentiates RollingFileAppender from its super
class.
@since 0.9.0
*/
protected
void subAppend(LoggingEvent event) {
super.subAppend(event);
if(fileName != null && qw != null) {
long size = ((CountingQuietWriter) qw).getCount();
if (size >= maxFileSize && size >= nextRollover) {
rollOver();
}
}
}
示例13: setFile
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
/**
* Creates and opens the file for logging. If <code>staticLogFileName</code>
* is false then the fully qualified name is determined and used.
*/
public synchronized void setFile(String fileName, boolean append) throws IOException {
if (!staticLogFileName) {
scheduledFilename = fileName = fileName.trim() + sdf.format(now);
if (countDirection > 0) {
scheduledFilename = fileName = fileName + '.' + (++curSizeRollBackups);
}
}
super.setFile(fileName, append);
if(append) {
File f = new File(fileName);
((CountingQuietWriter) qw).setCount(f.length());
}
}
示例14: setFile
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
public
synchronized
void setFile(boolean append) throws IOException {
long len = res.length();// this is done here, because in the location used the file is already locked
super.setFile(append);
if(append) {
((CountingQuietWriter) qw).setCount(len);
}
}
示例15: subAppend
import org.apache.log4j.helpers.CountingQuietWriter; //导入依赖的package包/类
/**
This method differentiates RollingFileAppender from its super
class.
@since 0.9.0
*/
protected void subAppend(LoggingEvent event) {
super.subAppend(event);
if(res != null && qw != null) {
long size = ((CountingQuietWriter) qw).getCount();
if (size >= maxFileSize && size >= nextRollover) {
rollOver();
}
}
}