本文整理汇总了Java中org.apache.logging.log4j.core.appender.rolling.RollingFileManager类的典型用法代码示例。如果您正苦于以下问题:Java RollingFileManager类的具体用法?Java RollingFileManager怎么用?Java RollingFileManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RollingFileManager类属于org.apache.logging.log4j.core.appender.rolling包,在下文中一共展示了RollingFileManager类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: RollingRandomAccessFileAppender
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
private RollingRandomAccessFileAppender(final String name, final Layout<? extends Serializable> layout,
final Filter filter, final RollingFileManager manager, final String fileName,
final String filePattern, final boolean ignoreExceptions,
final boolean immediateFlush, final Advertiser advertiser) {
super(name, layout, filter, ignoreExceptions, immediateFlush, manager);
if (advertiser != null) {
final Map<String, String> configuration = new HashMap<String, String>(
layout.getContentFormat());
configuration.put("contentType", layout.getContentType());
configuration.put("name", name);
advertisement = advertiser.advertise(configuration);
}
this.fileName = fileName;
this.filePattern = filePattern;
this.advertiser = advertiser;
}
开发者ID:OuZhencong,项目名称:log4j2,代码行数:17,代码来源:RollingRandomAccessFileAppender.java
示例2: createRollingFileAppender
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
/**
* Creates a new {@link RollingFileAppender}
* @param fileName The log file
* @param loggingConfig The logging config
* @param layout The layout
* @param strategy the rollover strategy
* @param rolledFileFormat The log file roll pattern
* @param trigger The roll trigger
* @return the new appender
*/
protected Appender createRollingFileAppender(final String fileName, Configuration loggingConfig, PatternLayout layout,
final DefaultRolloverStrategy strategy, final String rolledFileFormat, final TriggeringPolicy trigger) {
RollingFileManager fileManager = RollingFileManager.getFileManager(
fileName,
rolledFileFormat,
false,
true,
trigger,
strategy,
null,
layout,
8192,
true
);
trigger.initialize(fileManager);
return RollingFileAppender.createAppender(
fileName, // file name
rolledFileFormat, // rolled file name pattern
"true", // append
getClass().getSimpleName(), // appender name
"true", // buffered io
"8192", // buffer size
"true", // immediate flush
trigger, // triggering policy
strategy, // rollover strategy
layout, // layout
null, // filter
"true", // ignore exceptions
null, // advertise
null, // advertise uri
loggingConfig); // config
}
开发者ID:nickman,项目名称:HeliosStreams,代码行数:44,代码来源:LoggingWriter.java
示例3: rollover
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
/**
* Perform the rollover.
* @param manager The RollingFileManager name for current active log file.
* @return A RolloverDescription.
* @throws SecurityException if an error occurs.
*/
@Override
public RolloverDescription rollover(final RollingFileManager manager) throws SecurityException {
if (maxIndex < 0) {
return null;
}
final long start = System.nanoTime();
final int fileIndex = purge(minIndex, maxIndex, manager);
if (fileIndex < 0) {
return null;
}
if (LOGGER.isTraceEnabled()) {
final double duration = (System.nanoTime() - start) / (1000.0 * 1000.0 * 1000.0);
LOGGER.trace("DefaultRolloverStrategy.purge() took {} seconds", duration);
}
final StringBuilder buf = new StringBuilder(255);
manager.getPatternProcessor().formatFileName(subst, buf, fileIndex);
final String currentFileName = manager.getFileName();
String renameTo = buf.toString();
final String compressedName = renameTo;
Action compressAction = null;
if (renameTo.endsWith(EXT_GZIP)) {
renameTo = renameTo.substring(0, renameTo.length() - EXT_GZIP.length());
compressAction = new GzCompressAction(new File(renameTo), new File(compressedName), true);
} else if (renameTo.endsWith(EXT_ZIP)) {
renameTo = renameTo.substring(0, renameTo.length() - EXT_ZIP.length());
compressAction = new ZipCompressAction(new File(renameTo), new File(compressedName), true,
compressionLevel);
}
final FileRenameAction renameAction =
new FileRenameAction(new File(currentFileName), new File(renameTo), false);
return new RolloverDescriptionImpl(currentFileName, false, renameAction, compressAction);
}
开发者ID:dianping,项目名称:zebra,代码行数:43,代码来源:ZebraRolloverStrategy.java
示例4: RollingFileAppender
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
private RollingFileAppender(final String name, final Layout<? extends Serializable> layout, final Filter filter,
final RollingFileManager manager, final String fileName,
final String filePattern, final boolean ignoreExceptions, final boolean immediateFlush,
final Advertiser advertiser) {
super(name, layout, filter, ignoreExceptions, immediateFlush, manager);
if (advertiser != null) {
final Map<String, String> configuration = new HashMap<String, String>(layout.getContentFormat());
configuration.put("contentType", layout.getContentType());
configuration.put("name", name);
advertisement = advertiser.advertise(configuration);
}
this.fileName = fileName;
this.filePattern = filePattern;
this.advertiser = advertiser;
}
开发者ID:OuZhencong,项目名称:log4j2,代码行数:16,代码来源:RollingFileAppender.java
示例5: RollingFileAppender
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
private RollingFileAppender(final String name, final Layout<? extends Serializable> layout, final Filter filter,
final RollingFileManager manager, final String fileName, final String filePattern,
final boolean ignoreExceptions, final boolean immediateFlush, final Advertiser advertiser) {
super(name, layout, filter, ignoreExceptions, immediateFlush, manager);
if (advertiser != null) {
final Map<String, String> configuration = new HashMap<>(layout.getContentFormat());
configuration.put("contentType", layout.getContentType());
configuration.put("name", name);
advertisement = advertiser.advertise(configuration);
}
this.fileName = fileName;
this.filePattern = filePattern;
this.advertiser = advertiser;
}
开发者ID:apache,项目名称:logging-log4j2,代码行数:15,代码来源:RollingFileAppender.java
示例6: initialize
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
@Override
public final void initialize(final RollingFileManager manager) {
this.manager = manager;
}
开发者ID:emc-mongoose,项目名称:mongoose-base,代码行数:5,代码来源:StepIdTriggeringPolicy.java
示例7: purge
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
private int purge(final int lowIndex, final int highIndex, final RollingFileManager manager) {
return useMax ? purgeAscending(lowIndex, highIndex, manager) :
purgeDescending(lowIndex, highIndex, manager);
}
开发者ID:dianping,项目名称:zebra,代码行数:5,代码来源:ZebraRolloverStrategy.java
示例8: append
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
/**
* Write the log entry rolling over the file when required.
* @param event The LogEvent.
*/
@Override
public void append(final LogEvent event) {
((RollingFileManager) getManager()).checkRollover(event);
super.append(event);
}
开发者ID:OuZhencong,项目名称:log4j2,代码行数:11,代码来源:RollingFileAppender.java
示例9: createAppender
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
/**
* Create a RollingFileAppender.
* @param fileName The name of the file that is actively written to. (required).
* @param filePattern The pattern of the file name to use on rollover. (required).
* @param append If true, events are appended to the file. If false, the file
* is overwritten when opened. Defaults to "true"
* @param name The name of the Appender (required).
* @param bufferedIO When true, I/O will be buffered. Defaults to "true".
* @param immediateFlush When true, events are immediately flushed. Defaults to "true".
* @param policy The triggering policy. (required).
* @param strategy The rollover strategy. Defaults to DefaultRolloverStrategy.
* @param layout The layout to use (defaults to the default PatternLayout).
* @param filter The Filter or null.
* @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
* they are propagated to the caller.
* @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
* @param advertiseURI The advertised URI which can be used to retrieve the file contents.
* @param config The Configuration.
* @return A RollingFileAppender.
*/
@PluginFactory
public static RollingFileAppender createAppender(
@PluginAttribute("fileName") final String fileName,
@PluginAttribute("filePattern") final String filePattern,
@PluginAttribute("append") final String append,
@PluginAttribute("name") final String name,
@PluginAttribute("bufferedIO") final String bufferedIO,
@PluginAttribute("immediateFlush") final String immediateFlush,
@PluginElement("Policy") final TriggeringPolicy policy,
@PluginElement("Strategy") RolloverStrategy strategy,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filter") final Filter filter,
@PluginAttribute("ignoreExceptions") final String ignore,
@PluginAttribute("advertise") final String advertise,
@PluginAttribute("advertiseURI") final String advertiseURI,
@PluginConfiguration final Configuration config) {
final boolean isAppend = Booleans.parseBoolean(append, true);
final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
final boolean isBuffered = Booleans.parseBoolean(bufferedIO, true);
final boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
final boolean isAdvertise = Boolean.parseBoolean(advertise);
if (name == null) {
LOGGER.error("No name provided for FileAppender");
return null;
}
if (fileName == null) {
LOGGER.error("No filename was provided for FileAppender with name " + name);
return null;
}
if (filePattern == null) {
LOGGER.error("No filename pattern provided for FileAppender with name " + name);
return null;
}
if (policy == null) {
LOGGER.error("A TriggeringPolicy must be provided");
return null;
}
if (strategy == null) {
strategy = DefaultRolloverStrategy.createStrategy(null, null, null,
String.valueOf(Deflater.DEFAULT_COMPRESSION), config);
}
if (layout == null) {
layout = PatternLayout.createLayout(null, null, null, null, null);
}
final RollingFileManager manager = RollingFileManager.getFileManager(fileName, filePattern, isAppend,
isBuffered, policy, strategy, advertiseURI, layout);
if (manager == null) {
return null;
}
return new RollingFileAppender(name, layout, filter, manager, fileName, filePattern,
ignoreExceptions, isFlush, isAdvertise ? config.getAdvertiser() : null);
}
开发者ID:OuZhencong,项目名称:log4j2,代码行数:81,代码来源:RollingFileAppender.java
示例10: build
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
@Override
public RollingFileAppender build() {
// Even though some variables may be annotated with @Required, we must still perform validation here for
// call sites that build builders programmatically.
final boolean isBufferedIo = isBufferedIo();
final int bufferSize = getBufferSize();
if (getName() == null) {
LOGGER.error("RollingFileAppender '{}': No name provided.", getName());
return null;
}
if (!isBufferedIo && bufferSize > 0) {
LOGGER.warn("RollingFileAppender '{}': The bufferSize is set to {} but bufferedIO is not true", getName(), bufferSize);
}
if (filePattern == null) {
LOGGER.error("RollingFileAppender '{}': No file name pattern provided.", getName());
return null;
}
if (policy == null) {
LOGGER.error("RollingFileAppender '{}': No TriggeringPolicy provided.", getName());
return null;
}
if (strategy == null) {
if (fileName != null) {
strategy = DefaultRolloverStrategy.newBuilder()
.withCompressionLevelStr(String.valueOf(Deflater.DEFAULT_COMPRESSION))
.withConfig(getConfiguration())
.build();
} else {
strategy = DirectWriteRolloverStrategy.newBuilder()
.withCompressionLevelStr(String.valueOf(Deflater.DEFAULT_COMPRESSION))
.withConfig(getConfiguration())
.build();
}
} else if (fileName == null && !(strategy instanceof DirectFileRolloverStrategy)) {
LOGGER.error("RollingFileAppender '{}': When no file name is provided a DirectFilenameRolloverStrategy must be configured");
return null;
}
final Layout<? extends Serializable> layout = getOrCreateLayout();
final RollingFileManager manager = RollingFileManager.getFileManager(fileName, filePattern, append,
isBufferedIo, policy, strategy, advertiseUri, layout, bufferSize, isImmediateFlush(),
createOnDemand, filePermissions, fileOwner, fileGroup, getConfiguration());
if (manager == null) {
return null;
}
manager.initialize();
return new RollingFileAppender(getName(), layout, getFilter(), manager, fileName, filePattern,
isIgnoreExceptions(), isImmediateFlush(), advertise ? getConfiguration().getAdvertiser() : null);
}
开发者ID:apache,项目名称:logging-log4j2,代码行数:56,代码来源:RollingFileAppender.java
示例11: initialize
import org.apache.logging.log4j.core.appender.rolling.RollingFileManager; //导入依赖的package包/类
@Override
public void initialize(RollingFileManager rfm) {
}
开发者ID:enolgor,项目名称:webapp-stack,代码行数:5,代码来源:ForcedTriggeringPolicy.java
注:本文中的org.apache.logging.log4j.core.appender.rolling.RollingFileManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论