-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loggerの利用方法 #14
Comments
基本は公式ページに説明されてある。 |
Loggerの設定方法として、
|
この設定で |
このパッケージではロギングメッセージを
MyMessages_en_US.properties
MyMessages_ja_JP.properties
以下のようなJavaファイルを作成することでログメッセージを切り替えることができる. import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Logger;
public class LocaleChangeExample {
public static void main(String[] args) {
// 英語のResourceBundleを使用するLogger
ResourceBundle bundleEN = ResourceBundle.getBundle("MyMessages", Locale.US);
Logger loggerEN = Logger.getLogger("TestLogger", bundleEN.getBaseBundleName());
// ログ出力(英語)
loggerEN.info(loggerEN.getResourceBundle().getString("greeting")); // Output: Hello
// 日本語のResourceBundleを使用するLogger
ResourceBundle bundleJA = ResourceBundle.getBundle("MyMessages", Locale.JAPAN);
Logger loggerJA = Logger.getLogger("TestLogger", bundleJA.getBaseBundleName());
// ログ出力(日本語)
loggerJA.info(loggerJA.getResourceBundle().getString("greeting")); // Output: こんにちは
}
} |
標準で提供されているLoggerを利用する手順を書く
The text was updated successfully, but these errors were encountered: