Hello everyone,
coming from the old log4j I'm trying to migrate our XML configuration into just 
code.
Sadly I cannot find any info about how to set a rolloverStrategy 
programmatically.
I am using this code to initialize a mainLogBuilder.

LayoutComponentBuilder layoutBuilder = 
builder.newLayout("PatternLayout").addAttribute("pattern", LOG_PATTERN);
ComponentBuilder triggeringRollFile = 
builder.newComponent("Policies").addComponent(builder.newComponent("SizeBasedTriggeringPolicy").addAttribute("size",
 LOG_SIZE));

builder.add(builder.newFilter("ThresholdFilter", Filter.Result.ACCEPT, 
Filter.Result.NEUTRAL).addAttribute("level", Level.INFO));
AppenderComponentBuilder mainLogBuilder = builder
        .newAppender("mainLog", "RollingFile")
        .addAttribute("fileName", "log/main.log")
        .addAttribute("filePattern", "log/main.%i.log")
        .add(layoutBuilder)
        .addComponent(triggeringRollFile);

But I want to set the max number of backup files to 5. How do I do this?

Thanks in advance

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to