记录器应该是最终的和静态的吗? [英] Should be logger always final and static?

查看:115
本文介绍了记录器应该是最终的和静态的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以从许多线程访问类。在这种情况下必须是记录器也是最终的和静态的吗?
谢谢。

Class can be accessed from many threads. Must be logger in this case also be final and static? Thanks.

推荐答案

所有主要的java日志包( java.util.logging log4j 等)是同步的和线程安全的。即使从多个线程调用类,每个类的私有最终静态记录器的标准模式也很好。

All major java logging packages (java.util.logging, log4j, etc.) are synchronized and thread safe. The standard pattern of a private final static logger per class is fine even if the class is called from multiple threads.

这篇关于记录器应该是最终的和静态的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆