実際には、ログ設定を確認するためにリスナーが必要です。 リスナーはすべてのロガークラスをチェックし、設定を変更する場合は許可しません。リスナーを使用してロガーの設定を確認するにはどうすればよいですか?
ありがとう
実際には、ログ設定を確認するためにリスナーが必要です。 リスナーはすべてのロガークラスをチェックし、設定を変更する場合は許可しません。リスナーを使用してロガーの設定を確認するにはどうすればよいですか?
ありがとう
このpart of documentationは、実行時に設定をロードする方法について説明します。 logback.xml
ファイルをjarまたはwarに埋め込み、リソースとしてロードするには、次の例を見てください。
InputStream is = YourClass.class.getResourceAsStream("embedded-logback-log.xml");
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
// Call context.reset() to clear any previous configuration, e.g. default
// configuration. For multi-step configuration, omit calling context.reset().
context.reset();
// Here you load the new configuration
configurator.doConfigure(is);
} catch (JoranException je) {
// StatusPrinter will handle this
}
StatusPrinter.printInCaseOfErrorsOrWarnings(context);
logger.info("Entering application.");
JoranConfiguratorを使用していただきありがとうございます。「情報」レベルでログインするように強制クラスを設定することはできますか? –
変更ログレベルが "情報"または必要なものであれば、新しい構成をロード(または作成)できます。 – freedev
ありがとう、私は私の質問を変更しました。自分のログ設定を継続的にチェックするためにリスナーが必要です。 –
は、実行時にlogback設定ファイルを設定する方法[のhttp://stackoverflow.com/questions/30939814/how-to-set-logback-configuration-file-at-runtime – freedev
可能な重複の重複している可能性があり?](http://stackoverflow.com/questions/30939814/how-to-set-logback-configuration-file-at-runtime) –