您发布的警告看起来很像Java Util Logging消息,由于Log4J是一个不同的框架,因此不会被Log4J控制.您可以在VM的"logging.properties"文件中禁用该消息:org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.level=SEVERE或者您可以将 SLF4J 添加到您的项目中,以将旧框架消息重定向到Log4J.为此,请 slf4j-api.jar , jcl-over-slf4j.jar , jul-to-slf4j.jar 和 slf4j-log4j12.jar . I have some warnings which I want to disable. They comes from the org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelperclass. So I am using log4j and I call at rutimeLogger.getLogger("org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper").setLevel(Level.OFF);but nothing happens. For that purpose I debug the problematic code and first 3 times the warn was displayed, but on the 4-th hit the level was changed.I changed the log level at the begging(in the constructor) so I suppose there is some refresh mechanism in the log4j when the runtime applied rule is take into account.Is there a way to trigger this to happen immediately?Edit:The warning message is:WARNING: Property http://localhost:8080/dwa/rm/urn:rational::1-55422447386d3378-M-00000200/types/attrDef-7 could not be parsed as datatype http://www.w3.org/2001/XMLSchema#dateTimecom.hp.hpl.jena.datatypes.DatatypeFormatException: Lexical form '2015-06-10' is not a legal instance of Datatype[http://www.w3.org/2001/XMLSchema#dateTime -> class com.hp.hpl.jena.datatypes.xsd.XSDDateTime] Lexical form '2015-06-10' is not a legal instance of Datatype[http://www.w3.org/2001/XMLSchema#dateTime -> class com.hp.hpl.jena.datatypes.xsd.XSDDateTime] during parse -org.apache.xerces.impl.dv.InvalidDatatypeValueException: cvc-datatype-valid.1.2.1: '2015-06-10' is not a valid value for 'dateTime'. at com.hp.hpl.jena.graph.impl.LiteralLabelImpl.getValue(LiteralLabelImpl.java:339) at com.hp.hpl.jena.graph.Node_Literal.getLiteralValue(Node_Literal.java:39) at com.hp.hpl.jena.rdf.model.impl.LiteralImpl.getValue(LiteralImpl.java:98) 解决方案 The warning you posted looks much like a Java Util Logging message, those wont be controled by Log4J because its a different framework. You can either disable the message in your VMs "logging.properties" file:org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.level=SEVEREOr you can add SLF4J to your project to redirect legacy framework messages to Log4J. To do this put slf4j-api.jar, jcl-over-slf4j.jar, jul-to-slf4j.jar and slf4j-log4j12.jar in your classpath. 这篇关于在运行时更改外部类日志记录级别后如何刷新log4j的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-18 20:08