net.anotheria.asg.generator.apputil.Log4JConfigurationGenerator Maven / Gradle / Ivy
package net.anotheria.asg.generator.apputil;
import net.anotheria.asg.generator.AbstractGenerator;
import net.anotheria.asg.generator.FileEntry;
import net.anotheria.asg.generator.GeneratedXMLFile;
import net.anotheria.asg.generator.GeneratorDataRegistry;
import net.anotheria.asg.generator.IGenerateable;
import net.anotheria.asg.generator.IGenerator;
import net.anotheria.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Log4j configuration generator.
*
* Comment: In version 2.5.1 migration to slf4j was done and this file doesn't seem to be needed and can be removed in future.
*/
public class Log4JConfigurationGenerator extends AbstractGenerator implements IGenerator {
/**
* Logging levels.
*/
private static final String[] categories = new String[]{"debug","info","warn","error", "fatal"};
/**
* Name of generated package.
*/
public static final String GENERATED_PACKAGE = "net.anotheria.anosite.gen";
public List generate(IGenerateable g) {
List files = new ArrayList();
GeneratedXMLFile log4Config = generateContent();
log4Config.setPath("/etc/appdata");
FileEntry entry = new FileEntry(log4Config);
entry.setType(".xml");
files.add(entry);
return files;
}
private GeneratedXMLFile generateContent(){
GeneratedXMLFile artefact = new GeneratedXMLFile("log4j", "UTF-8");
startNewJob(artefact);
appendString("");
appendString("");
increaseIdent();
emptyline();
appendString("");
emptyline();
for (String cat : categories){
appendString("");
appendString("");
increaseIdent();
appendString("");
appendString("");
appendString(" ");
appendString("");
appendString("");
increaseIdent();
appendString("");
decreaseIdent();
appendString(" ");
decreaseIdent();
appendString(" ");
}
emptyline();
appendString("");
emptyline();
for (String cat : categories){
appendString("");
appendString("");
increaseIdent();
appendString("");
appendString("");
appendString(" ");
appendString("");
appendString("");
increaseIdent();
appendString("");
decreaseIdent();
appendString(" ");
decreaseIdent();
appendString(" ");
}
emptyline();
appendString("");
appendString("");
increaseIdent();
appendString("");
appendString("");
increaseIdent();
appendString("");
decreaseIdent();
appendString(" ");
decreaseIdent();
appendString(" ");
emptyline();
appendString("");
increaseIdent();
appendString(" ");
for (String cat : categories)
appendString(" ");
decreaseIdent();
appendString(" ");
emptyline();
appendString("");
increaseIdent();
appendString(" ");
for (String cat : categories)
appendString(" ");
decreaseIdent();
appendString(" ");
emptyline();
decreaseIdent();
appendString(" ");
return artefact;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy