Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,我目前在我的 .properties 文件中有这个:
java.util.logging.FileHandler.pattern = %h/programName%u%g.log
我还想在此附加时间戳/用户名,以便轻松识别日志文件有人知道吗?
由于 FileHandler 方法没有日期的 % 替换变量,我的建议是在将字符串传递给 FileHandler 之前格式化一个包含日期的字符串。就像是:
String pattern = String.format("%%h/programName%tYmd%%u%%g.log", today); FileHandler fh = new FileHandler(pattern);