本文整理汇总了Java中org.apache.log4j.ConsoleAppender.setName方法的典型用法代码示例。如果您正苦于以下问题:Java ConsoleAppender.setName方法的具体用法?Java ConsoleAppender.setName怎么用?Java ConsoleAppender.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.ConsoleAppender
的用法示例。
在下文中一共展示了ConsoleAppender.setName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
System.setProperty("log4j.defaultInitOverride", "true");
LogManager.resetConfiguration();
ConsoleAppender ca = new ConsoleAppender(new PatternLayout("%-5p - %m%n"));
ca.setName("edits");
LogManager.getRootLogger().addAppender(ca);
Options ops = new Options();
ops.addOption("optimize", false, "");
ops.addOption("balance", false, "");
ops.addOption("rules", false, "");
ops.addOption("debug", false, "");
ops.addOption("wordnet", true, "");
CommandLine commandLine = new BasicParser().parse(ops, args);
if (!commandLine.hasOption("debug"))
ca.setThreshold(Level.INFO);
RunExperiment res = new RunExperiment(commandLine.getArgs()[0], commandLine.hasOption("balance"),
commandLine.hasOption("optimize"), commandLine.hasOption("rules"));
if (commandLine.hasOption("wordnet"))
res.setRulesSource(new WordnetRulesSource(commandLine.getOptionValue("wordnet")));
res.train(commandLine.getArgs()[1]);
}
示例2: setUp
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public void setUp() {
System.setProperty( "javax.net.ssl.keyStore", TlsTest.class.getResource("testkeys").getPath() );
System.setProperty( "javax.net.ssl.trustStore", TlsTest.class.getResource("testkeys").getPath() );
System.setProperty( "javax.net.ssl.keyStorePassword", "passphrase" );
System.setProperty( "javax.net.ssl.keyStoreType", "jks" );
ConsoleAppender console = new ConsoleAppender();
console.setName("Console app");
String PATTERN = "%d [%p|%c|%C{1}] %m%n";
console.setLayout(new PatternLayout(PATTERN));
console.setThreshold(Level.DEBUG);
console.activateOptions();
Logger.getRootLogger().addAppender(console);
this.websocketServer = new WebsocketServer();
this.websocketBrowser = new WebsocketBrowser();
}
示例3: loggerSetup
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/**
* Just some logging set up here.
*/
private void loggerSetup() {
logger = TesttoolConfig.getLogger();
logger.setLevel(Level.INFO);
console = Logger.getLogger("de.wwu.testtool.test.console");
console.setLevel(Level.INFO);
ConsoleAppender consoleAppender = new ConsoleAppender(new PatternLayout("%-5p [%t:%r] %M(): %m%n"));
consoleAppender.setName("Console Appender");
//consoleAppender.setLayout(new PatternLayout("[%r] %20.20M(): %m%n") );
consoleAppender.setLayout(new PatternLayout("%m%n") );
console.addAppender(consoleAppender);
}
示例4: loggerSetup
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
private void loggerSetup() {
logger = TesttoolConfig.getLogger();
logger.setLevel(Level.DEBUG);
logger.debug("Debug");
logger.info("Info");
console = Logger.getLogger("de.wwu.testtool.test.console");
console.setLevel(Level.INFO);
ConsoleAppender consoleAppender = new ConsoleAppender(new PatternLayout("%-5p [%t:%r] %M(): %m%n"));
consoleAppender.setName("Console Appender");
consoleAppender.setLayout(new PatternLayout("[%r] %20.20M(): %m%n") );
console.addAppender(consoleAppender);
}
示例5: SetConsoleLogger
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public static void SetConsoleLogger(Level level) {
ConsoleAppender ca = new ConsoleAppender();
ca.setThreshold(level);
ca.setName("ConsoleLogger_Info");
ca.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
ca.activateOptions();
Logger.getRootLogger().getLoggerRepository().resetConfiguration();
Logger.getRootLogger().addAppender(ca);
}
示例6: initConsoleLog
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/**
* Defines an appender that writes INFO log messages to the console.
*/
public static void initConsoleLog()
{
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.setName("ConsoleLogger");
consoleAppender.setLayout(new PatternLayout(" [%p] %d [%t] %x %c %M - %m%n"));
LevelRangeFilter levelRangeFilter = new LevelRangeFilter();
levelRangeFilter.setLevelMax(Level.INFO);
levelRangeFilter.setLevelMin(Level.INFO);
consoleAppender.addFilter(levelRangeFilter);
consoleAppender.activateOptions();
Logger.getRootLogger().addAppender(consoleAppender);
}
示例7: configureLog4J
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public static void configureLog4J()
{
Logger root = Logger.getRootLogger();
root.setLevel(Level.DEBUG);
ConsoleAppender consoleAppender = new ConsoleAppender(new PatternLayout("%d{HH:mm:ss.SSS} %c{2} [%t] %p - %m%n"));
consoleAppender.setName("CONSOLE");
if (root.getAppender("CONSOLE") == null)
root.addAppender(consoleAppender);
Logger.getLogger("org.logicalcobwebs").setLevel(Level.WARN);
}
示例8: initConsoleLog
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/**
* Defines an appender that writes INFO log messages to the console.
*/
public static void initConsoleLog() {
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.setName("ConsoleLogger");
consoleAppender.setLayout(new PatternLayout("[%-5p]\t%d\t%c\t%x\t-\t%m%n"));
LevelRangeFilter levelRangeFilter = new LevelRangeFilter();
consoleAppender.addFilter(levelRangeFilter);
consoleAppender.activateOptions();
Logger.getRootLogger().addAppender(consoleAppender);
}
示例9: configureLog4J
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
/**
* Configures the Log4J properties
*
* @param logFilePath
* The log file path
*/
private void configureLog4J(String logFilePath) {
// This is the root logger provided by log4j
Logger rootLogger = Logger.getRootLogger();
rootLogger.setLevel(Level.DEBUG);
// Define log pattern layout
PatternLayout layout = new PatternLayout("[%-5p] %d %c - %m%n");
// Add console appender to root logger
if (rootLogger.getAppender(LOG_CONSOLE_APPENDER_NAME) == null) {
ConsoleAppender consoleAppender = new ConsoleAppender(layout);
consoleAppender.setName(LOG_CONSOLE_APPENDER_NAME);
rootLogger.addAppender(consoleAppender);
}
// Add file appender with layout and output log file name
try {
if (rootLogger.getAppender(LOG_FILE_APPENDER_NAME) == null) {
RollingFileAppender fileAppender = new RollingFileAppender(
layout, logFilePath);
fileAppender.setAppend(false);
fileAppender.setImmediateFlush(true);
fileAppender.setName(LOG_FILE_APPENDER_NAME);
fileAppender.setMaxFileSize("5MB");
fileAppender.setMaxBackupIndex(10);
rootLogger.addAppender(fileAppender);
}
} catch (IOException e) {
System.out.println("Failed to add appender !!");
}
}
示例10: installConsoleAppender
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
private void installConsoleAppender() {
ConsoleAppender console = new ConsoleAppender();
console.setName("Console");
console.setThreshold(logLevel);
console.setLayout(new PatternLayout(PATTERN));
console.setFollow(true);
console.activateOptions();
Logger.getRootLogger().addAppender(console);
}
示例11: createConsoleAppender
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
private void createConsoleAppender() {
ConsoleAppender appender = new ConsoleAppender();
appender.setName(STRING_APPENDER_NAME);
appender.setLayout(new PatternLayout(
"%-5p %d{yyyy-MM-dd HH:mm:ss.SSS 'GMT'Z} %c{1} [%t] - %m%n"));
appender.activateOptions();
appender.setThreshold(Level.DEBUG);
Logger.getLogger(ImJavaApiLogger.class).addAppender(appender);
}
示例12: setUp
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
Logger defaultLogger = Logger.getLogger(StopWatch.DEFAULT_LOGGER_NAME);
ConsoleAppender stdErrAppender = new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_ERR);
stdErrAppender.setName("log4jStdErrAppender");
stdErrAppender.activateOptions();
defaultLogger.addAppender(stdErrAppender);
}
示例13: solverManagerTest
import org.apache.log4j.ConsoleAppender; //导入方法依赖的package包/类
public void solverManagerTest() {
// set up logging and solver manager
logger = TesttoolConfig.getLogger();
logger.setLevel(Level.TRACE);
texLogger = TesttoolConfig.getTexLogger();
texLogger.setLevel(Level.DEBUG);
console = Logger.getLogger("de.wwu.testtool.test.console");
console.setLevel(Level.DEBUG);
ConsoleAppender consoleAppender = new ConsoleAppender(new PatternLayout("%-5p [%t:%r] %M(): %m%n"));
consoleAppender.setName("Console Appender");
consoleAppender.setLayout(new PatternLayout("[%r] %20.20M(): %m%n") );
console.addAppender(consoleAppender);
// setup some stuff
solverManager = new SolverManagerOld();
ConstraintExpression constraint = null;
// linear program with doubles
// constraint = this.simpleLinearProgramDouble();
// solverManager.addConstraint(constraint);
// this.solve();
// solverManager.removeConstraint();
// linear program with integer
// constraint = this.simpleLinearProgramInteger();
// solverManager.addConstraint(constraint);
// this.solve();
// solverManager.removeConstraint();
// linear program with integer
// constraint = this.simpleLinearProgramInteger2();
// solverManager.addConstraint(constraint);
// this.solve();
// solverManager.removeConstraint();
// transformation tests
constraint = this.transformationTest();
solverManager.addConstraint(constraint);
//solverManager.addConstraint( Not.newInstance(constraint) );
//solverManager.addConstraint( this.simpleLinearProgramDouble() );
this.solve();
//solverManager.removeConstraint();
//solverManager.removeConstraint();
solverManager.removeConstraint();
// type casts
// constraint = this.simpleExpressionWithTypeCasts();
// solverManager.addConstraint(constraint);
// this.solve();
// solverManager.removeConstraint();
// non linear
// constraint = this.simpleNonLinearProgram();
// solverManager.addConstraint(constraint);
// this.solve();
// solverManager.removeConstraint();
// boolean mixed with linear double
// constraint = this.simpleLinearProgramDouble();
// solverManager.addConstraint(Xor.newInstance(this.booleanTest(), constraint));
// this.solve();
// solverManager.removeConstraint();
// boolean
// solverManager.addConstraint(this.booleanTest());
// this.solve();
// solverManager.removeConstraint();
// boolean combined with linear
// constraint = BooleanEqual.newInstance(Not.newInstance(constraint), this.booleanTest());
// solverManager.addConstraint(constraint);
// this.solve();
// solverManager.removeConstraint();
}