确定!所以我正在为我的服务器开发一个控制台过滤器插件(FTB,Monster,1.6.4)。 我已经在阻止我设置的控制台日志方面取得了相当大的成功,但是他们有一些日志我遇到了困难。 以下是我的控制台中的一部分:
21.04 12:43:02 [Server] Startup [2.0.2] Recieved client info from DirtyRedz
21.04 12:43:00 [Server] INFO [ConsoleFilter] Message was blocked: Sending serverside check to: DirtyRedz
21.04 12:43:00 [Server] INFO [ConsoleFilter] Checking message: Sending serverside check to: DirtyRedz
21.04 12:43:00 [Server] INFO [ConsoleFilter] Message was blocked: Loading Player: DirtyRedz
21.04 12:43:00 [Server] INFO [ConsoleFilter] Checking message: Loading Player: DirtyRedz
21.04 12:43:00 [Server] INFO Sending config data to DirtyRedz
21.04 12:43:00 [Multicraft] DirtyRedz ran command Message of the Day
21.04 12:43:00 [ConsoleFilter] Checking message: DirtyRedz ran command Message of the Day
21.04 12:43:00 [Connect] User DirtyRedz, IP 11.1.1.111
21.04 12:43:00 [Connect] User [ConsoleFilter] Checking message: DirtyRedz, IP 11.1.1.111
带有“[ConsoleFilter]检查消息的日志:”我正在使用进行测试,在此消息之后仍然运行的任何内容都是因为我允许它。我只是遇到以下日志的问题:
我这里有两个问题: 1. [Multicraft] DirtyRedz运行命令当天的消息,正在通过记录器运行,但是在我的代码有机会检查日志并停止它之前它被批准。 对于这个日志真的很好奇,如果你测试它是否getMessage()== null,它会传递true,但你仍然可以用record.getMessage()调用它,它会显示。
这是我的相关代码块:
@Override
public void onEnable() {
getLogger().info("[ConsoleFilter] onEnable has been invoked!");//Bukkit has initialized ConsoleFilter
fillFromConfig();
Bukkit.getLogger().setFilter(new Filter() {
@Override
public boolean isLoggable(LogRecord record) {
getLogger().info("[ConsoleFilter] Checking message: " + record.getMessage());
Set<String> keyset=nodesHashMap.keySet();
for(String i:keyset){
String str = i;
if(consoleFiltering && !nodesHashMap.get(i).getDelete()){
if(nodesHashMap.get(i).getList() == "Contains"){
if(record.getMessage().toLowerCase().contains(str.toLowerCase())){
Date time = Calendar.getInstance().getTime();
logToFile(time + " | " + record.getLevel() +
" | " +record.getMessage(),nodesHashMap.get(i).getFile(),"Logs");
getLogger().info("[ConsoleFilter] Message was blocked: " + record.getMessage());
return false;
}
}else if(nodesHashMap.get(i).getList() == "Ends_With"){
if(record.getMessage().toLowerCase().endsWith(str.toLowerCase())){
Date time = Calendar.getInstance().getTime();
logToFile(time + " | " + record.getLevel() +
" | " +record.getMessage(),nodesHashMap.get(i).getFile(),"Logs");
getLogger().info("[ConsoleFilter] Message was blocked: " + record.getMessage());
return false;
}
}else if(nodesHashMap.get(i).getList() == "Equals"){
if(record.getMessage().toLowerCase().equals(str.toLowerCase())){
Date time = Calendar.getInstance().getTime();
logToFile(time + " | " + record.getLevel() +
" | " +record.getMessage(),nodesHashMap.get(i).getFile(),"Logs");
getLogger().info("[ConsoleFilter] Message was blocked: " + record.getMessage());
return false;
}
}
}
}
return true;
}
});
答案 0 :(得分:0)
这是因为multicraft不支持日志过滤apis,因此无论如何都会写入日志。