@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);
}
java类org.apache.log4j.helpers.CountingQuietWriter的实例源码
DailySizeRollingAppender.java 文件源码
项目:Equella
阅读 27
收藏 0
点赞 0
评论 0
DailySizeRollingAppender.java 文件源码
项目:Equella
阅读 26
收藏 0
点赞 0
评论 0
@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);
}
CompositeRollingAppender.java 文件源码
项目:cacheonix-core
阅读 28
收藏 0
点赞 0
评论 0
/**
* 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);
}
MttangLog4jRollingFileAppender.java 文件源码
项目:cambodia
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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();
}
}
}
CompositeRollingAppender.java 文件源码
项目:nabs
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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);
}
QpidCompositeRollingAppender.java 文件源码
项目:andes
阅读 24
收藏 0
点赞 0
评论 0
/**
* 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);
}
QpidCompositeRollingAppender.java 文件源码
项目:andes
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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());
}
}
RollingFileWithoutDeleteAppender.java 文件源码
项目:incubator-sentry
阅读 16
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
RollingFileWithoutDeleteAppender.java 文件源码
项目:incubator-sentry
阅读 27
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
SizeRollingFileAppender.java 文件源码
项目:ats-framework
阅读 17
收藏 0
点赞 0
评论 0
/**
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();
}
}
}
DailySizeRollingAppender.java 文件源码
项目:Equella
阅读 22
收藏 0
点赞 0
评论 0
@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());
}
}
DailySizeRollingAppender.java 文件源码
项目:Equella
阅读 28
收藏 0
点赞 0
评论 0
@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());
}
}
ExtendedRollingFileAppender.java 文件源码
项目:carbondata
阅读 21
收藏 0
点赞 0
评论 0
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();
}
}
}
}
GroupRollingFileAppender.java 文件源码
项目:jcode
阅读 19
收藏 0
点赞 0
评论 0
@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);
}
}
}
}
RollingFileAppender.java 文件源码
项目:cacheonix-core
阅读 22
收藏 0
点赞 0
评论 0
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());
}
}
RollingFileAppender.java 文件源码
项目:cacheonix-core
阅读 18
收藏 0
点赞 0
评论 0
/**
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();
}
}
}
CompositeRollingAppender.java 文件源码
项目:cacheonix-core
阅读 20
收藏 0
点赞 0
评论 0
/**
* 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());
}
}
RollingFileAppender.java 文件源码
项目:daq-eclipse
阅读 20
收藏 0
点赞 0
评论 0
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());
}
}
RollingFileAppender.java 文件源码
项目:daq-eclipse
阅读 19
收藏 0
点赞 0
评论 0
/**
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();
}
}
}
RollingResourceAppender.java 文件源码
项目:Lucee4
阅读 19
收藏 0
点赞 0
评论 0
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);
}
}
RollingResourceAppender.java 文件源码
项目:Lucee4
阅读 21
收藏 0
点赞 0
评论 0
/**
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();
}
}
}
RollingResourceAppender.java 文件源码
项目:Lucee
阅读 21
收藏 0
点赞 0
评论 0
@Override
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);
}
}
RollingResourceAppender.java 文件源码
项目:Lucee
阅读 27
收藏 0
点赞 0
评论 0
/**
This method differentiates RollingFileAppender from its super
class.
@since 0.9.0
*/
@Override
protected void subAppend(LoggingEvent event) {
super.subAppend(event);
if(res != null && qw != null) {
long size = ((CountingQuietWriter) qw).getCount();
if (size >= maxFileSize && size >= nextRollover) {
rollOver();
}
}
}
RollingFileAppender.java 文件源码
项目:nabs
阅读 21
收藏 0
点赞 0
评论 0
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());
}
}
RollingFileAppender.java 文件源码
项目:nabs
阅读 20
收藏 0
点赞 0
评论 0
/**
This method differentiates RollingFileAppender from its super
class.
@since 0.9.0
*/
protected
void subAppend(LoggingEvent event) {
super.subAppend(event);
if((fileName != null) &&
((CountingQuietWriter) qw).getCount() >= maxFileSize)
this.rollOver();
}
CompositeRollingAppender.java 文件源码
项目:nabs
阅读 20
收藏 0
点赞 0
评论 0
/**
* 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());
}
}
QpidCompositeRollingAppender.java 文件源码
项目:andes
阅读 19
收藏 0
点赞 0
评论 0
/**
* Implements roll overs base on file size.
*
* <p>If the maximum number of size based backups is reached (<code>curSizeRollBackups == maxSizeRollBackups</code)
* then the oldest file is deleted -- it's index determined by the sign of countDirection.<br> If
* <code>countDirection</code> < 0, then files {<code>File.1</code>, ..., <code>File.curSizeRollBackups -1</code>}
* are renamed to {<code>File.2</code>, ..., <code>File.curSizeRollBackups</code>}. Moreover, <code>File</code> is
* renamed <code>File.1</code> and closed.<br>
*
* A new file is created to receive further log output.
*
* <p>If <code>maxSizeRollBackups</code> is equal to zero, then the <code>File</code> is truncated with no backup
* files created.
*
* <p>If <code>maxSizeRollBackups</code> < 0, then <code>File</code> is renamed if needed and no files are deleted.
*/
// synchronization not necessary since doAppend is alreasy synched
protected void rollOverSize()
{
File file;
this.closeFile(); // keep windows happy.
LogLog.debug("rolling over count=" + ((CountingQuietWriter) qw).getCount());
LogLog.debug("maxSizeRollBackups = " + maxSizeRollBackups);
LogLog.debug("curSizeRollBackups = " + curSizeRollBackups);
LogLog.debug("countDirection = " + countDirection);
// If maxBackups <= 0, then there is no file renaming to be done.
if (maxSizeRollBackups != 0)
{
rollFile();
}
try
{
// This will also close the file. This is OK since multiple
// close operations are safe.
this.setFile(baseFileName, false);
}
catch (IOException e)
{
LogLog.error("setFile(" + fileName + ", false) call failed.", e);
}
}
RollingFileWithoutDeleteAppender.java 文件源码
项目:incubator-sentry
阅读 19
收藏 0
点赞 0
评论 0
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());
}
}
RollingFileWithoutDeleteAppender.java 文件源码
项目:incubator-sentry
阅读 20
收藏 0
点赞 0
评论 0
/**
* This method differentiates RollingFileAppender from its super class.
*/
protected void subAppend(LoggingEvent event) {
super.subAppend(event);
if (fileName != null && qw != null) {
long size = ((CountingQuietWriter) qw).getCount();
if (size >= maxFileSize && size >= nextRollover) {
rollOver();
}
}
}
RollingFileWithoutDeleteAppender.java 文件源码
项目:incubator-sentry
阅读 20
收藏 0
点赞 0
评论 0
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());
}
}