本文整理匯總了Java中org.apache.log4j.BasicConfigurator.configure方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicConfigurator.configure方法的具體用法?Java BasicConfigurator.configure怎麽用?Java BasicConfigurator.configure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.log4j.BasicConfigurator
的用法示例。
在下文中一共展示了BasicConfigurator.configure方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getWriter
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
/**
* Get singleton instance of RdfWriter
*
* @return instance of RdfWriter
*/
public static RdfWriter getWriter() {
if (writer == null) {
BasicConfigurator.configure();
writer = new RdfWriter();
}
writer.model = ModelFactory.createDefaultModel();
writer.list = new LinkedBlockingQueue<>();
return writer;
}
示例2: before
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Override
public void before() throws Throwable {
if (notConfigured) {
//Now configure Log4J with console appender
BasicConfigurator.configure();
System.out.println("Configure Log4J for basic output...");
System.out.println("Set root LOGGER loglevel to '" + rootLevel.toString() + "'!");
Logger.getRootLogger().setLevel(rootLevel);
}
if (logger == null) {
Logger.getRootLogger().setAdditivity(false);
logger = Logger.getLogger(InitLog4jLoggingRule.class);
logger.setAdditivity(false);
}
//Init FirstSpirit Logging with special logger
Logging.init(new FS2Log4JLogger());
}
示例3: main
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
public static void main(String[] args) throws ParseException {
Options options = new Options();
Option nameOption = new Option("n", true, "Name to resolve");
nameOption.setRequired(true);
options.addOption(nameOption);
CommandLineParser parser = new BasicParser();
CommandLine cmd = parser.parse(options, args);
BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.DEBUG);
PodCIDRToNodeMapping plugin = new PodCIDRToNodeMapping();
Configuration conf = new Configuration();
plugin.setConf(conf);
String nameToResolve = cmd.getOptionValue(nameOption.getOpt());
List<String> networkPathDirs = plugin.resolve(Lists.newArrayList(nameToResolve));
log.info("Resolved " + nameToResolve + " to " + networkPathDirs);
}
示例4: clockSkewFailure_CorrectsGlobalTimeOffset
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
/**
* In the following test, we purposely setting the time offset to trigger a clock skew error.
* The time offset must be fixed and then we validate the global value for time offset has been
* update.
*/
@Test
public void clockSkewFailure_CorrectsGlobalTimeOffset() throws Exception {
BasicConfigurator.configure();
final int originalOffset = SdkGlobalTime.getGlobalTimeOffset();
final int skew = 3600;
SdkGlobalTime.setGlobalTimeOffset(skew);
assertEquals(skew, SdkGlobalTime.getGlobalTimeOffset());
SQSAsyncClient sqsClient = createSqsAyncClient();
sqsClient.listQueues(ListQueuesRequest.builder().build()).thenCompose( __ -> {
assertThat("Clockskew is fixed!", SdkGlobalTime.getGlobalTimeOffset(), lessThan(skew));
// subsequent changes to the global time offset won't affect existing client
SdkGlobalTime.setGlobalTimeOffset(skew);
return sqsClient.listQueues(ListQueuesRequest.builder().build());
}).thenAccept( __ -> {
assertEquals(skew, SdkGlobalTime.getGlobalTimeOffset());
}).join();
sqsClient.close();
SdkGlobalTime.setGlobalTimeOffset(originalOffset);
}
示例5: main
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
public static void main(String[] args) {
try {
BasicConfigurator.configure();
Debug.info(" - Initializing Hibernate ... ");
_RootDAO.initialize();
ApplicationProperties.getConfigProperties().setProperty(
ApplicationProperty.CustomizationDefaultCourseUrl.key(),
"http://syllabuskrk.agh.edu.pl/:years/pl/magnesite/modules/:courseNbr");
ApplicationProperties.getConfigProperties().setProperty("unitime.custom.default.course_api_url",
"http://syllabuskrk.agh.edu.pl/api/:years/modules/:courseNbr");
ApplicationProperties.getDefaultProperties()
.setProperty(ApplicationProperty.CustomizationDefaultCourseDetailsDownload.key(), "true");
System.out.println("URL:" + new AGHCourseDetailsProvider()
.getCourseUrl(new AcademicSessionInfo(231379l, "2015", "Semestr zimowy", "AGH"), "BAND", "101"));
System.out.println("Details:\n" + new AGHCourseDetailsProvider()
.getDetails(new AcademicSessionInfo(231379l, "2015", "Semestr zimowy", "AGH"), "BAND", "101"));
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: main
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
/**
* main.
* @param args {@link String}{@code []}
* @throws IOException due to file errors.
*/
@SuppressWarnings("nls")
public static void main(final String[] args) throws IOException {
BasicConfigurator.configure();
final File in = new File("src/test/mp3/1000Hz.mp3");
// assume there is just one id 3 tag at the very beginning...
final ID3Tag firstID3Tag = MPEGAudio.decodeFirstID3Tag(in);
if (LOG.isInfoEnabled()) {
LOG.info("" + firstID3Tag); //$NON-NLS-1$
}
final DecodingResult dr = MPEGAudio.decode(in, MPEGAudioContentFilter.MPEG_AUDIO_FRAMES);
// final File out = File.createTempFile("TestIntegrationReadWrite-TEST", ".mp3"); //$NON-NLS-1$ //$NON-NLS-2$
final File out = new File("out.mp3");
if (LOG.isInfoEnabled()) {
LOG.info("Created tmp file [" + out.getAbsolutePath() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
}
try (FileOutputStream fos = new FileOutputStream(out)) {
final WaveFormGainFilter filter = new CosineGainFilter();
filter.setWavelengthInSecs(20f);
// Filter filter = new FixFactorGainFIlter(0.9);
MPEGAudio.encode(dr.getContent(), filter, fos, true);
}
}
示例7: main
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
public static void main(String[] args) {
BasicConfigurator.configure();
port(4567);
if (getPassword() != null && getKeystorePath() != null) {
secure(getKeystorePath(), getPassword(), null, null);
}
staticFiles.location("/public");
staticFiles.expireTime(600L);
before("*", Filters.addTrailingSlashes);
before("*", Filters.handleLocaleChange);
get(Path.Web.INDEX, IndexController.serveIndexPage);
get(Path.Web.PARSE, DatalogController.parseDatalog);
after("*", Filters.addGzipHeader);
}
示例8: testLog4JAppendString
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Test
public void testLog4JAppendString() throws Exception {
BasicConfigurator.configure();
org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("com.db.fxpricing.Logger");
for(long i = 0; i < WARMUP_COUNT; i++)
log.info("value");
Thread.sleep(1000L);
objectCounting.set(true);
for(long i = 0; i < TEST_COUNT; i++)
log.info("value");
Thread.sleep(500L);
printState("log4j-string");
}
示例9: init
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init(ServletConfig config) throws ServletException {
// Put your code here
System.out.println("Log4jServlet 正在初始化log4j日誌設置信息");
String log4jLocation = config.getInitParameter("log4j-properties-location");
ServletContext sc = config.getServletContext();
if(log4jLocation == null){
System.out.println("** 沒有log4j-properties-location 初始化文件,所以使用BasicConfiguratorc初始化 **");
BasicConfigurator.configure();
}else{
String webAppPath = sc.getRealPath("/");
String log4jProp = webAppPath + log4jLocation;
File log4File = new File(log4jProp);
if(log4File.exists()){
System.out.println("使用:"+ log4jProp + "初始化日誌設置信息");
PropertyConfigurator.configure(log4jProp);
}else{
System.out.println("*****" + log4jProp + "文件沒有找到,所以使用BasicConfigurator初始化*****");
BasicConfigurator.configure();
}
}
super.init(config);
System.out.println("---------log4jServlet 初始化log4j日誌設置信息完成--------");
}
示例10: testLog4JAppendLongs
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Test
public void testLog4JAppendLongs() throws Exception {
BasicConfigurator.configure();
org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("com.db.fxpricing.Logger");
for(long i = 0; i < WARMUP_COUNT; i++)
log.info("value:" + i + " " + i + " " + i + " " + i + " " + i
+ i + " " + i + " " + i + " " + i + " " + i);
Thread.sleep(1000L);
objectCounting.set(true);
for(long i = 0; i < TEST_COUNT; i++)
log.info("value:" + i + " " + i + " " + i + " " + i + " " + i
+ i + " " + i + " " + i + " " + i + " " + i);
Thread.sleep(500L);
printState("log4j-longs");
}
示例11: testBson
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Test
public void testBson () throws IOException
{
BasicConfigurator.configure ();
String f = "../tests/data/data1.bson";
File file = new File (f.replace ('/', File.separatorChar));
JsonPathProvider provider = new JsonPathProvider ();
Configuration pathConfig = Configuration.defaultConfiguration ().jsonProvider (provider);
JsonPath path = JsonPath.compile ("$..A");
JsonProvider p = new CookJsonProvider ();
HashMap<String, Object> readConfig = new HashMap<String, Object> ();
readConfig.put (CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_BSON);
readConfig.put (CookJsonProvider.ROOT_AS_ARRAY, Boolean.TRUE);
JsonReaderFactory rf = p.createReaderFactory (readConfig);
JsonReader reader = rf.createReader (new FileInputStream (file));
JsonStructure obj = reader.read ();
reader.close ();
JsonValue value = path.read (obj, pathConfig);
Assert.assertEquals ("[1,3,5,7]", provider.toJson (value));
}
示例12: before
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Before
public void before() throws Exception {
BasicConfigurator.configure();
Scheduler.$.initLogging();
File storageFile = Files.createTempFile(MesosTestCase.class.getSimpleName(), null).toFile();
assertTrue(storageFile.delete());
Nodes.storage = Storage.file(storageFile);
Nodes.reset();
Scheduler.Config config = Scheduler.$.config;
config.api = "http://localhost:" + Net.findAvailPort();
config.jar = new File("hdfs-mesos-0.1.jar");
config.hadoop = new File("hadoop-1.2.1.tar.gz");
Cli.api = config.api;
Scheduler.$.subscribed(schedulerDriver, "id", new Master());
}
示例13: main
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
public static void main(String[] args) throws InterruptedException {
// Configure console logging
BasicConfigurator.configure();
String topic = "publishing_to_topic";
if (args.length > 0) {
topic = args[0];
}
System.out.println("Publishing to topic " + topic);
while (!Thread.currentThread().isInterrupted()) {
String s = RandomStringUtils.randomAlphanumeric(10);
PubSub.publish(topic, s);
Thread.sleep(1000);
}
}
示例14: init
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
/**
* @param defaultLogSettingsPath
* Path to the default log settings
* @param logsDirectory
* Path to the directory where the log files are stored
*/
public static void init(String defaultLogSettingsPath, String logsDirectory) {
Properties settings = new Properties();
try (InputStream is = FileUtils.getResourceInputStream(defaultLogSettingsPath)) {
settings.load(is);
} catch (IOException e) {
Log.log.error("Could not load default log settings: " + e.getMessage());
}
String filePattern = "'jhv.'yyyy-MM-dd'T'HH-mm-ss'.log'";
settings.setProperty("log4j.appender.file.Directory", logsDirectory);
settings.setProperty("log4j.appender.file.Pattern", filePattern);
SimpleDateFormat formatter = new SimpleDateFormat(filePattern);
formatter.setTimeZone(TimeZone.getTimeZone(System.getProperty("user.timezone")));
settings.setProperty("log4j.appender.file.TimeStamp", formatter.format(new Date()));
BasicConfigurator.configure();
PropertyConfigurator.configure(settings);
}
示例15: setUp
import org.apache.log4j.BasicConfigurator; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
BasicConfigurator.configure();
servlet = new MainServlet();
ctx = mock(ConfigContext.class);
ConfigContext.overwriteCurrentInstance(ctx);
session = mock(HttpSession.class);
request = mock(HttpServletRequest.class);
when(request.getSession(true)).thenReturn(session);
when(request.getRequestURL()).thenReturn(new StringBuffer("http://test.localhost:1234/annotator/home"));
outputBuf = new StringWriter();
PrintWriter output = new PrintWriter(outputBuf);
response = mock(HttpServletResponse.class);
when(response.getWriter()).thenReturn(output);
}