本文整理匯總了Java中org.apache.log4j.Level類的典型用法代碼示例。如果您正苦於以下問題:Java Level類的具體用法?Java Level怎麽用?Java Level使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Level類屬於org.apache.log4j包,在下文中一共展示了Level類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: putApplicationProgress
import org.apache.log4j.Level; //導入依賴的package包/類
@PUT
@Path(WebStructure.APPLICATION_PROGRESS_PATH)
@Consumes({MediaType.APPLICATION_JSON})
public Response putApplicationProgress(
@Context HttpServletRequest hsr,
@PathParam(WebStructure.FRAMEWORK_NAME_PATH_PARAM) String frameworkName,
OverrideApplicationProgressRequest overrideApplicationProgressRequest) throws Exception {
LOGGER.logSplittedLines(Level.INFO,
"[%s]: putApplicationProgress: \n%s",
frameworkName, WebCommon.toJson(overrideApplicationProgressRequest));
ModelValidation.validate(frameworkName);
ModelValidation.validate(overrideApplicationProgressRequest);
requestManager.updateApplicationProgress(frameworkName, overrideApplicationProgressRequest);
return Response
.status(HttpStatus.SC_ACCEPTED)
.header("Location", hsr.getRequestURL())
.build();
}
示例2: getLevel
import org.apache.log4j.Level; //導入依賴的package包/類
public Level getLevel(int traceLevel) {
if ( traceLevel == TRACE_INFO ) {
return Level.INFO;
} else if ( traceLevel == TRACE_ERROR ) {
return Level.ERROR;
} else if ( traceLevel == TRACE_DEBUG) {
return Level.DEBUG;
} else if (traceLevel == TRACE_TRACE) {
return Level.ALL;
} else {
return Level.OFF;
}
}
示例3: testReconnectWaringLog
import org.apache.log4j.Level; //導入依賴的package包/類
/**
* 重連日誌的校驗
*/
@Test
public void testReconnectWaringLog() throws RemotingException, InterruptedException{
int port = NetUtils.getAvailablePort();
DubboAppender.doStart();
String url = "exchange://127.0.0.4:"+port + "/client.reconnect.test?check=false&"
+Constants.RECONNECT_KEY+"="+1 //1ms reconnect,保證有足夠頻率的重連
+"&"+Constants.SHUTDOWN_TIMEOUT_KEY+ "=1"//shutdown時間足夠短,確保error日誌輸出
+"&reconnect.waring.period=100";//每隔多少warning記錄一次
try{
Exchangers.connect(url);
}catch (Exception e) {
//do nothing
}
int count = 0;
for (int i=0;i<100;i++){
count = LogUtil.findMessage(Level.WARN, "client reconnect to ") ;
if (count >=1){
break;
}
Thread.sleep(50);//重連線程的運行
}
Assert.assertTrue("warning message count must >= 1, real :"+count, count>= 1);
DubboAppender.doStop();
}
示例4: onDialogRequest
import org.apache.log4j.Level; //導入依賴的package包/類
@Override
public void onDialogRequest(CAPDialog capDialog, CAPGprsReferenceNumber referenceNumber) {
synchronized (this) {
if (capDialog instanceof CAPDialogCircuitSwitchedCall) {
CAPDialogCircuitSwitchedCall dlg = (CAPDialogCircuitSwitchedCall) capDialog;
CAPDialogCircuitSwitchedCall curDialog = this.currentDialog;
currentRequestDef = "";
if (curDialog == null) {
this.currentDialog = dlg;
this.testerHost
.sendNotif(SOURCE_NAME, "DlgAccepted:", "TrId=" + capDialog.getRemoteDialogId(), Level.DEBUG);
} else {
try {
capDialog.abort(CAPUserAbortReason.congestion);
} catch (CAPException e) {
this.testerHost.sendNotif(SOURCE_NAME, "Exception when rejecting Dialog", e.toString(), Level.DEBUG);
}
this.testerHost.sendNotif(SOURCE_NAME, "Rejected incoming Dialog:",
"TrId=" + capDialog.getRemoteDialogId(), Level.DEBUG);
}
}
}
}
示例5: testReconnectErrorLog
import org.apache.log4j.Level; //導入依賴的package包/類
/**
* 重連日誌的校驗,不能一直拋出error日誌.
*/
@Test
public void testReconnectErrorLog() throws RemotingException, InterruptedException{
int port = NetUtils.getAvailablePort();
DubboAppender.doStart();
String url = "exchange://127.0.0.3:"+port + "/client.reconnect.test?check=false&"
+Constants.RECONNECT_KEY+"="+1 + //1ms reconnect,保證有足夠頻率的重連
"&"+Constants.SHUTDOWN_TIMEOUT_KEY+ "=1";//shutdown時間足夠短,確保error日誌輸出
try{
Exchangers.connect(url);
}catch (Exception e) {
//do nothing
}
Thread.sleep(1500);//重連線程的運行
Assert.assertEquals("only one error message ", 1 , LogUtil.findMessage(Level.ERROR, "client reconnect to "));
DubboAppender.doStop();
}
示例6: sendNotif
import org.apache.log4j.Level; //導入依賴的package包/類
public void sendNotif(String source, String msg, Throwable e, Level logLevel) {
StringBuilder sb = new StringBuilder();
for (StackTraceElement st : e.getStackTrace()) {
if (sb.length() > 0)
sb.append("\n");
sb.append(st.toString());
}
this.doSendNotif(source, msg + " - " + e.toString(), sb.toString());
logger.log(logLevel, msg, e);
// if (showInConsole) {
// logger.error(msg, e);
// } else {
// logger.debug(msg, e);
// }
}
示例7: logStackTrace
import org.apache.log4j.Level; //導入依賴的package包/類
public void logStackTrace(int traceLevel) {
if (needsLogging) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
StackTraceElement[] ste = new Exception().getStackTrace();
// Skip the log writer frame and log all the other stack frames.
for (int i = 1; i < ste.length; i++) {
String callFrame = "[" + ste[i].getFileName() + ":"
+ ste[i].getLineNumber() + "]";
pw.print(callFrame);
}
pw.close();
String stackTrace = sw.getBuffer().toString();
Level level = this.getLevel(traceLevel);
Priority priority = this.getLogPriority();
if ( level.isGreaterOrEqual(priority)) {
logger.log(level,stackTrace);
}
}
}
示例8: configureLogging
import org.apache.log4j.Level; //導入依賴的package包/類
public static boolean configureLogging() {
if (!_RootDAO.isConfigured()) return false;
org.hibernate.Session hibSession = ApplicationConfigDAO.getInstance().createNewSession();
try {
for (ApplicationConfig config: (List<ApplicationConfig>)hibSession.createQuery("from ApplicationConfig where key like 'log4j.logger.%'").list()) {
Level level = Level.toLevel(config.getValue());
boolean root = "log4j.logger.root".equals(config.getKey());
Logger logger = (root ? Logger.getRootLogger() : Logger.getLogger(config.getKey().substring("log4j.logger.".length())));
logger.setLevel(level);
Debug.info("Logging level for " + logger.getName() + " set to " + level);
}
} finally {
hibSession.close();
}
return true;
}
示例9: append
import org.apache.log4j.Level; //導入依賴的package包/類
@Override
public void append(LoggingEvent event) {
Level level = event.getLevel();
// depends on the api, == might not work
// see HADOOP-7055 for details
if (level.equals(Level.INFO)) {
counts.incr(INFO);
}
else if (level.equals(Level.WARN)) {
counts.incr(WARN);
}
else if (level.equals(Level.ERROR)) {
counts.incr(ERROR);
}
else if (level.equals(Level.FATAL)) {
counts.incr(FATAL);
}
}
示例10: setup
import org.apache.log4j.Level; //導入依賴的package包/類
@Before
public void setup() throws Exception {
conf = new HdfsConfiguration();
fsHelper = new FileSystemTestHelper();
// Set up java key store
String testRoot = fsHelper.getTestRootDir();
File testRootDir = new File(testRoot).getAbsoluteFile();
final Path jksPath = new Path(testRootDir.toString(), "test.jks");
conf.set(DFSConfigKeys.DFS_ENCRYPTION_KEY_PROVIDER_URI,
JavaKeyStoreProvider.SCHEME_NAME + "://file" + jksPath.toUri()
);
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
Logger.getLogger(EncryptionZoneManager.class).setLevel(Level.TRACE);
fs = cluster.getFileSystem();
fsWrapper = new FileSystemTestWrapper(cluster.getFileSystem());
fcWrapper = new FileContextTestWrapper(
FileContext.getFileContext(cluster.getURI(), conf));
dfsAdmin = new HdfsAdmin(cluster.getURI(), conf);
// Need to set the client's KeyProvider to the NN's for JKS,
// else the updates do not get flushed properly
fs.getClient().setKeyProvider(cluster.getNameNode().getNamesystem()
.getProvider());
DFSTestUtil.createKey(TEST_KEY, cluster, conf);
}
示例11: main
import org.apache.log4j.Level; //導入依賴的package包/類
/**
* Main entry point for the echo server application.
* @param args contains the port number at args[0].
*/
public static void main(String[] args) {
try {
new LogSetup("logs/client.log", Level.OFF);
app_KVClient app = new app_KVClient();
app.run();
} catch (IOException e) {
System.out.println("Error! Unable to initialize logger!");
e.printStackTrace();
System.exit(1);
}
}
示例12: isValidLevel
import org.apache.log4j.Level; //導入依賴的package包/類
public static boolean isValidLevel(String levelString) {
boolean valid = false;
if(levelString.equals(Level.ALL.toString())) {
valid = true;
} else if(levelString.equals(Level.DEBUG.toString())) {
valid = true;
} else if(levelString.equals(Level.INFO.toString())) {
valid = true;
} else if(levelString.equals(Level.WARN.toString())) {
valid = true;
} else if(levelString.equals(Level.ERROR.toString())) {
valid = true;
} else if(levelString.equals(Level.FATAL.toString())) {
valid = true;
} else if(levelString.equals(Level.OFF.toString())) {
valid = true;
}
return valid;
}
示例13: start
import org.apache.log4j.Level; //導入依賴的package包/類
public boolean start() {
this.countSriReq = 0;
this.countSriResp = 0;
this.countMtFsmReq = 0;
this.countMtFsmReqNot = 0;
this.countMtFsmResp = 0;
this.countMoFsmReq = 0;
this.countMoFsmResp = 0;
this.countIscReq = 0;
this.countRsmdsReq = 0;
this.countRsmdsResp = 0;
this.countAscReq = 0;
this.countAscResp = 0;
this.countErrRcvd = 0;
this.countErrSent = 0;
MAPProvider mapProvider = this.mapMan.getMAPStack().getMAPProvider();
mapProvider.getMAPServiceSms().acivate();
mapProvider.getMAPServiceSms().addMAPServiceListener(this);
mapProvider.addMAPDialogListener(this);
this.testerHost.sendNotif(SOURCE_NAME, "SMS Client has been started", "", Level.INFO);
isStarted = true;
return true;
}
示例14: getTagsForProperty
import org.apache.log4j.Level; //導入依賴的package包/類
public String[] getTagsForProperty(String propertyName) {
if (propertyName.equals("level")) {
return new String[]{
Level.ERROR.toString(),
Level.WARN.toString(),
Level.INFO.toString(),
Level.DEBUG.toString(),
Level.TRACE.toString(),
};
}
if (propertyName.equals("logger")) {
return new String[]{
Engine.logEngine.getName(),
Engine.logContext.getName(),
Engine.logUser.getName(),
Engine.logAudit.getName(),
};
}
return new String[0];
}
示例15: tesApplyUserLoggerLevels
import org.apache.log4j.Level; //導入依賴的package包/類
@Test
public void tesApplyUserLoggerLevels() {
// set the level
Logger.getLogger( "fake.logger" ).setLevel( Level.INFO );
// read the configuration and remember the level
RemoteLoggingConfigurator remoteLoggingConfig = new RemoteLoggingConfigurator( "127.0.0.1" );
// change the level in log4j
Logger.getLogger( "fake.logger" ).setLevel( Level.DEBUG );
assertTrue( Logger.getLogger( "fake.logger" ).getLevel().equals( Level.DEBUG ) );
assertTrue( remoteLoggingConfig.needsApplying() );
// apply the remembered level
remoteLoggingConfig.apply();
assertTrue( Logger.getLogger( "fake.logger" ).getLevel().equals( Level.INFO ) );
}