0
log4j 2を実装しようとしていますが、次のエラーがスローされ続けます。エラーStatusLogger Log4j2がロギング実装を見つけられませんでした
> ERROR StatusLogger Log4j2 could not find a logging implementation.
> Please add log4j-core to the classpath. Using SimpleLogger to log to
> the console...
> ERROR LogExample This Will Be Printed On Error
> FATAL LogExample This Will Be Printed On Fatal
私はネット上の解決策を試しました。しかし、私のために働いていないようです。
これは私が実行しようとしているコードです。
package demo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class LogExample {
private static final Logger LOG = LogManager.getLogger(LogExample.class);
public static void main(String[] args) {
LOG.debug("This Will Be Printed On Debug");
LOG.info("This Will Be Printed On Info");
LOG.warn("This Will Be Printed On Warn");
LOG.error("This Will Be Printed On Error");
LOG.fatal("This Will Be Printed On Fatal");
LOG.info("Appending string: {}.", "Hello, World");
}
}
のpom.xmlに追加したプロジェクトとの依存関係:
すべてのヘルプは高く評価されます。ありがとう。
log4j-core jarをクラスパスに追加する必要があります。私はあなたがmavenを使用していると仮定します。基本的に、あなたのコードだけを含むjarではなく、すべての依存関係を持つjarファイルを作成することでそれを行うことができます。これを行うには、maven shade pluginを見てください。 –
回答があればそれを受け入れるか、別の方法で解決することができればあなた自身の投稿を検討してください。 –
ご報告いただきありがとうございます。私は別の答えとして投稿した別の方法を見つけました。本当に助けに感謝します。 – Alok