简体   繁体   English

使用类路径的Java Util日志记录级别

[英]Java Util Logging Level using Classpath

is it possible to specify the logging level for java.util.logging using classpath? 是否可以使用类路径指定java.util.logging的日志记录级别? I don't want to use for that special file or create java class which overrides the default level. 我不想使用该特殊文件或创建覆盖默认级别的java类。

My point is to say something like this -Djava.util.logging.level=ERROR 我的意思是说这样的话-Djava.util.logging.level = ERROR

I can't find it in documentation, but maybe there are some tricks for that. 我在文档中找不到它,但是也许有一些技巧。

No, it is not possible. 不,不可能。 The Java Logging API can be configured either with a configuration class java.util.logging.config.class or with a configuration file. 可以使用配置类java.util.logging.config.class或配置文件来配置Java Logging API。 A default logging configuration file is located at "lib/logging.properties" , inside the JRE directory. 默认的日志记录配置文件位于JRE目录内的"lib/logging.properties"

You could change this configuration file (which is not the best idea as it will be used for all the programs running in this JRE) or you could set a separate configuration file for your application and set JVM property java.util.logging.config.file to point to this file 您可以更改此配置文件(这不是最好的主意,因为它将用于在此JRE中运行的所有程序),或者可以为应用程序设置单独的配置文件,并设置JVM属性java.util.logging.config.file指向该文件

-Djava.util.logging.config.file=/tmp/logging.properties

See this tutorial for more details on Java Logging configuration. 有关Java日志记录配置的更多详细信息,请参见本教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM