本文整理匯總了Java中org.apache.log4j.Category.getRoot方法的典型用法代碼示例。如果您正苦於以下問題:Java Category.getRoot方法的具體用法?Java Category.getRoot怎麽用?Java Category.getRoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.log4j.Category
的用法示例。
在下文中一共展示了Category.getRoot方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addIdeFatalMessage
import org.apache.log4j.Category; //導入方法依賴的package包/類
@Nullable
public LogMessage addIdeFatalMessage(final IdeaLoggingEvent aEvent) {
Object data = aEvent.getData();
final LogMessage message = data instanceof LogMessage ? (LogMessage)data : new LogMessage(aEvent);
if (myIdeFatals.size() < MAX_POOL_SIZE_FOR_FATALS) {
if (myFatalsGrouper.addToGroup(message)) {
return message;
}
} else if (myIdeFatals.size() == MAX_POOL_SIZE_FOR_FATALS) {
String msg = DiagnosticBundle.message("error.monitor.too.many.errors");
LogMessage tooMany = new LogMessage(new LoggingEvent(msg, Category.getRoot(), Priority.ERROR, null, new TooManyErrorsException()));
myFatalsGrouper.addToGroup(tooMany);
return tooMany;
}
return null;
}
示例2: testAppendNormalEvent
import org.apache.log4j.Category; //導入方法依賴的package包/類
@Test
public void testAppendNormalEvent(){
Category cat=Category.getRoot();
long date=System.currentTimeMillis();
Level level=Level.DEBUG;
String msg="this is a message";
String thread=Thread.currentThread().getName();
database.command(new OCommandSQL("delete from "+DB_TABLE_NAME)).execute();
LoggingEvent event= new LoggingEvent(null, cat,date , level, msg,thread , null, null, null, null);
appender.append(event);
appender.finalize();
List<ODocument> list=database.command(new OCommandSQL("select * from "+DB_TABLE_NAME+" limit 1")).execute();
ODocument result=list.get(0);
Assert.assertEquals(new Date(date), result.field(EventMapper.TIMESTAMP));
Assert.assertEquals(level.toString(),result.field(EventMapper.LEVEL));
Assert.assertEquals(msg,result.field(EventMapper.MESSAGE));
Assert.assertEquals(cat.getName(),result.field(EventMapper.LOGGER_NAME));
Assert.assertEquals(thread,result.field(EventMapper.THREAD));
}
示例3: testMapEvent
import org.apache.log4j.Category; //導入方法依賴的package包/類
@Test
public void testMapEvent(){
OrientdbEventMapper eventMapper= new OrientdbEventMapper();
LoggingEvent event= new LoggingEvent("te\"st", Category.getRoot(), System.currentTimeMillis(), Level.ALL, "This is a\" ' test", Thread.currentThread().getName(), null, null, null, null);
JSONObject obj=(JSONObject) eventMapper.mapEvent(1,event);
//System.out.println(obj.toString());
Assert.assertEquals(true, true);
}
示例4: testAppendNormalEvent
import org.apache.log4j.Category; //導入方法依賴的package包/類
@Test
public void testAppendNormalEvent(){
Category cat=Category.getRoot();
long date=System.currentTimeMillis();
Level level=Level.DEBUG;
String msg="this is a message";
String thread=Thread.currentThread().getName();
appender.getSession().execute("TRUNCATE log.log;");
LoggingEvent event= new LoggingEvent(null, cat,date , level, msg,thread , null, null, null, null);
appender.append(event);
//appender.finalize();
ResultSet results= appender.getSession().execute("SELECT * from log.log");
List<Row> list=results.all();
//Assert.assertEquals(true,true);
if(list!=null && list.size()>0)
{
Row row=list.get(0);
Assert.assertEquals(new Date(date), row.getDate(EventMapper.TIMESTAMP));
Assert.assertEquals(level.toString(),row.getString(EventMapper.LEVEL));
Assert.assertEquals(msg,row.getString(EventMapper.MESSAGE));
Assert.assertEquals(cat.getName(),row.getString(EventMapper.LOGGER_NAME));
Assert.assertEquals(thread,row.getString(EventMapper.THREAD));
}
else
Assert.fail();
/*
database.command(new OCommandSQL("delete from "+DB_TABLE_NAME)).execute();
LoggingEvent event= new LoggingEvent(null, cat,date , level, msg,thread , null, null, null, null);
appender.append(event);
appender.finalize();
List<ODocument> list=database.command(new OCommandSQL("select * from "+DB_TABLE_NAME+" limit 1")).execute();
ODocument result=list.get(0);
Assert.assertEquals(new Date(date), result.field(EventMapper.TIMESTAMP));
Assert.assertEquals(level.toString(),result.field(EventMapper.LEVEL));
Assert.assertEquals(msg,result.field(EventMapper.MESSAGE));
Assert.assertEquals(cat.getName(),result.field(EventMapper.LOGGER_NAME));
Assert.assertEquals(thread,result.field(EventMapper.THREAD));
*/
}